public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Pandoc: Shift every block code block by 2 spaces (or 4 spaces)
@ 2019-08-07 18:29 Nikhil Agarwal
  0 siblings, 0 replies; only message in thread
From: Nikhil Agarwal @ 2019-08-07 18:29 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 1620 bytes --]

I write a lot of code within a list such as follows:

---

- The general method to edit a file, assuming **command** is the command 
that edits the file, is something along these lines:

```bash
$ command file > tempfile && mv tempfile file
# or, depending on how "command" reads its input
$ command < file > tempfile && mv tempfile file
```

- To prepend data to a file, similarly do:

```bash
$ { command; cat file; } > tempfile && mv tempfile file
```

  where **command** is the command that produces the output that should be 
prepended to the file.

- The use of "&&" ensures that the original file is overwritten only if no 
errors occurred during the processing. That is to safeguard the original 
data in case something goes wrong. If preserving the original inode number 
(and thus permissions and other metadata) is a concern, there are various 
ways, here are two:

```bash
$ command file > tempfile && cat tempfile > file && rm tempfile
# or
$ cp file tempfile && command tempfile > file && rm tempfile
```

---

How can I write a Pandoc filter, that shifts all the codeblock (that start 
at column 0) by 2 spaces (or 4 spaces if the previous list has a number 
like `#.  ` or `1.  ` or `10. `) ?

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/38b01a91-5289-49e8-aa02-fd09aa92daec%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 3554 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-08-07 18:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-07 18:29 Pandoc: Shift every block code block by 2 spaces (or 4 spaces) Nikhil Agarwal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).