public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* How to avoid backslashes when converting to Markdown
@ 2020-04-07 13:39 Thomas Byskov Dalgaard
       [not found] ` <703897C2-8129-4A1B-A486-D4CCDB0F3088-AHfMSizzl90sTMJHDOTzqX9LOBIZ5rWg@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Byskov Dalgaard @ 2020-04-07 13:39 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

[-- Attachment #1: Type: text/plain, Size: 1980 bytes --]

Hello!

I tried to cleanup a Markdown document and forgot to make a blank line before an unordered list. I used the * as the listmarker. When I opened my converted Markdown document it showed \* instead of *

I then did some other tests and found that Pandoc will insert backslashes in other different cases. Such as:

* If a line contains something like: file_name.txt
this is converted to: file\_name.txt
even when I use Pandoc's own Markdown that does not use the underscore character for emphasising, so why is a backslash inserted here?
* If I type a $ with spaces around this is backslashed as well.

The manual states that all symbols can be escapable, but what if I just want my document to be converted without having any backslashes inserted at all?
My command is:

pandoc -f markdown-escaped_line_breaks-all_symbols_escapable-intraword_underscores -t markdown-escaped_line_breaks-all_symbols_escapable-intraword_underscores --wrap=none --atx-headers -s --o document-converted.md document.md

I have attached a sample file with some samples where I got backslashes inserted, but instead I would like to see a warning if any syntax may be invalid.
Or if I later on notice I may have typed something wrong I would much appreciate if I could correct this and convert again without getting any additional characters into my document.

Would a filter be the way to go here, or am I doing something wrong in my Pandoc commandline workflow?
Tested this on Mac OS 10.15.4 Pandoc 2.92.1 installed from the binary pkg-package.

Thanks in advance.

Best regards Thomas

-- 
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/703897C2-8129-4A1B-A486-D4CCDB0F3088%40coolfortheblind.dk.

[-- Attachment #2: sample document with auto inserted backslashes.md --]
[-- Type: application/octet-stream, Size: 510 bytes --]

# Document with unwanted inserted backslashes

## Lists

Here is a unordered list that broke because I forgot the blank line before the list
\* This is the first list item.
\* And here is the second item.

But these two next examples does not get a backslash at all:
- First.
- Second
- Third.

This example doesn't get backslashes inserted either:
+ First
+ Second
+ Third


# Other cases with backslashes.

This product costs 10 \$ 
This is a sample path with a backslash inserted:
directory/file\_name.txt


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How to avoid backslashes when converting to Markdown
       [not found] ` <703897C2-8129-4A1B-A486-D4CCDB0F3088-AHfMSizzl90sTMJHDOTzqX9LOBIZ5rWg@public.gmane.org>
@ 2020-04-08 16:35   ` John MacFarlane
  0 siblings, 0 replies; 2+ messages in thread
From: John MacFarlane @ 2020-04-08 16:35 UTC (permalink / raw)
  To: Thomas Byskov Dalgaard, pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


You could write a filter that breaks all strings on characters
like `_`, `*`, etc. and converts these to RawInline "markdown"
elements.  It's a bit fussy because e.g. you'll transform

    Str "hi_there"

to three inlines

    [Str "hi", RawInline (Format "markdown") "_", Str "there"]

Have a look at lua's patterns and string functions.

Thomas Byskov Dalgaard <tbdlist-AHfMSizzl90sTMJHDOTzqX9LOBIZ5rWg@public.gmane.org> writes:

> Hello!
>
> I tried to cleanup a Markdown document and forgot to make a blank line before an unordered list. I used the * as the listmarker. When I opened my converted Markdown document it showed \* instead of *
>
> I then did some other tests and found that Pandoc will insert backslashes in other different cases. Such as:
>
> * If a line contains something like: file_name.txt
> this is converted to: file\_name.txt
> even when I use Pandoc's own Markdown that does not use the underscore character for emphasising, so why is a backslash inserted here?
> * If I type a $ with spaces around this is backslashed as well.
>
> The manual states that all symbols can be escapable, but what if I just want my document to be converted without having any backslashes inserted at all?
> My command is:
>
> pandoc -f markdown-escaped_line_breaks-all_symbols_escapable-intraword_underscores -t markdown-escaped_line_breaks-all_symbols_escapable-intraword_underscores --wrap=none --atx-headers -s --o document-converted.md document.md
>
> I have attached a sample file with some samples where I got backslashes inserted, but instead I would like to see a warning if any syntax may be invalid.
> Or if I later on notice I may have typed something wrong I would much appreciate if I could correct this and convert again without getting any additional characters into my document.
>
> Would a filter be the way to go here, or am I doing something wrong in my Pandoc commandline workflow?
> Tested this on Mac OS 10.15.4 Pandoc 2.92.1 installed from the binary pkg-package.
>
> Thanks in advance.
>
> Best regards Thomas
>
> -- 
> 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/703897C2-8129-4A1B-A486-D4CCDB0F3088%40coolfortheblind.dk.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-04-08 16:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-07 13:39 How to avoid backslashes when converting to Markdown Thomas Byskov Dalgaard
     [not found] ` <703897C2-8129-4A1B-A486-D4CCDB0F3088-AHfMSizzl90sTMJHDOTzqX9LOBIZ5rWg@public.gmane.org>
2020-04-08 16:35   ` John MacFarlane

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).