parent
39a69c4f93
commit
5a6399d9f6
6 changed files with 16 additions and 7 deletions
|
@ -43,7 +43,11 @@ import Text.Pandoc.Writers.Markdown.Types (MarkdownVariant(..),
|
|||
-- | Escape special characters for Markdown.
|
||||
escapeText :: WriterOptions -> Text -> Text
|
||||
escapeText opts = T.pack . go . T.unpack
|
||||
where
|
||||
where
|
||||
startsWithSpace (' ':_) = True
|
||||
startsWithSpace ('\t':_) = True
|
||||
startsWithSpace [] = True
|
||||
startsWithSpace _ = False
|
||||
go [] = []
|
||||
go (c:cs) =
|
||||
case c of
|
||||
|
@ -59,7 +63,10 @@ escapeText opts = T.pack . go . T.unpack
|
|||
| isAlphaNum d || d == '_' || d == '{'
|
||||
-> '\\':'@':go cs
|
||||
_ -> '@':go cs
|
||||
_ | c `elem` ['\\','`','*','_','[',']','#'] ->
|
||||
'#' | isEnabled Ext_space_in_atx_header opts
|
||||
, startsWithSpace cs
|
||||
-> '\\':'#':go cs
|
||||
_ | c `elem` ['\\','`','*','_','[',']'] ->
|
||||
'\\':c:go cs
|
||||
'|' | isEnabled Ext_pipe_tables opts -> '\\':'|':go cs
|
||||
'^' | isEnabled Ext_superscript opts -> '\\':'^':go cs
|
||||
|
@ -81,6 +88,8 @@ escapeText opts = T.pack . go . T.unpack
|
|||
| isEnabled Ext_intraword_underscores opts
|
||||
, isAlphaNum c
|
||||
, isAlphaNum x -> c : '_' : x : go xs
|
||||
'#':xs -> c : '#' : go xs
|
||||
'>':xs -> c : '>' : go xs
|
||||
_ -> c : go cs
|
||||
|
||||
attrsToMarkdown :: Attr -> Doc Text
|
||||
|
|
|
@ -6,7 +6,7 @@ and properly escaped.
|
|||
ok
|
||||
^D
|
||||
---
|
||||
title: \<this\> \*that\*
|
||||
title: \<this> \*that\*
|
||||
---
|
||||
|
||||
ok
|
||||
|
|
|
@ -26,6 +26,6 @@ Here is inline html:
|
|||
|
||||
Here is inline html:
|
||||
|
||||
\<div\> \<balise\> bla bla \</div\>
|
||||
\<div> \<balise> bla bla \</div>
|
||||
|
||||
```
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
% pandoc -t gfm
|
||||
\<hi\>
|
||||
^D
|
||||
\<hi\>
|
||||
\<hi>
|
||||
```
|
||||
|
|
|
@ -90,7 +90,7 @@ references:
|
|||
- family: Ryde
|
||||
given: Ulf
|
||||
container-title: Journal of Computational Chemistry
|
||||
doi: "10.1002/(SICI)1096-987X(199803)19:4\\<377::AID-JCC1\\>3.0.CO;2-P"
|
||||
doi: "10.1002/(SICI)1096-987X(199803)19:4\\<377::AID-JCC1>3.0.CO;2-P"
|
||||
id: sigfridsson
|
||||
issue: 4
|
||||
issued: 1998
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
</outline>
|
||||
<outline text="LaTeX" _note="- - 2 + 2 = 4 - *x* ∈ *y* - *α* ∧ *ω* - 223 - *p*-Tree - Here’s some display math: $$\\frac{d}{dx}f(x)=\\lim\_{h\\to 0}\\frac{f(x+h)-f(x)}{h}$$ - Here’s one that has a line break in it: *α* + *ω* × *x*². These shouldn’t be math: - To get the famous equation, write `$e = mc^2$`. - $22,000 is a *lot* of money. So is $34,000. (It worked if “lot” is emphasized.) - Shoes ($20) and socks ($5). - Escaped `$`: $73 *this should be emphasized* 23$. Here’s a LaTeX table: ------------------------------------------------------------------------">
|
||||
</outline>
|
||||
<outline text="Special Characters" _note="Here is some unicode: - I hat: Î - o umlaut: ö - section: § - set membership: ∈ - copyright: © AT&T has an ampersand in their name. AT&T is another way to write it. This & that. 4 &lt; 5. 6 &gt; 5. Backslash: \\ Backtick: \` Asterisk: \* Underscore: \_ Left brace: { Right brace: } Left bracket: \[ Right bracket: \] Left paren: ( Right paren: ) Greater-than: &gt; Hash: \# Period: . Bang: ! Plus: + Minus: - ------------------------------------------------------------------------">
|
||||
<outline text="Special Characters" _note="Here is some unicode: - I hat: Î - o umlaut: ö - section: § - set membership: ∈ - copyright: © AT&T has an ampersand in their name. AT&T is another way to write it. This & that. 4 &lt; 5. 6 &gt; 5. Backslash: \\ Backtick: \` Asterisk: \* Underscore: \_ Left brace: { Right brace: } Left bracket: \[ Right bracket: \] Left paren: ( Right paren: ) Greater-than: &gt; Hash: # Period: . Bang: ! Plus: + Minus: - ------------------------------------------------------------------------">
|
||||
</outline>
|
||||
<outline text="Links">
|
||||
<outline text="Explicit" _note="Just a [URL](/url/). [URL and title](/url/ "title"). [URL and title](/url/ "title preceded by two spaces"). [URL and title](/url/ "title preceded by a tab"). [URL and title](/url/ "title with "quotes" in it") [URL and title](/url/ "title with single quotes") [with\_underscore](/url/with_underscore) [Email link](mailto:nobody@nowhere.net) [Empty]().">
|
||||
|
|
Loading…
Add table
Reference in a new issue