git.iko.soy/typeable/pandoc
on master help sign in
Markdown reader: fix small super/subscript issue.

Superscripts and subscripts cannot contain spaces, but newlines were previously allowed (unintentionally). This led to bad interactions in some cases with footnotes. E.g. ``` foo^[note] bar^[note] ``` With this change newlines are also not allowed inside super/subscripts. Closes #5878.

commit741b1f7fb4f974a0fc2a9abe410007b27078e129 authorJohn MacFarlane <jgm@berkeley.edu> dateMon 11 Nov 2019, 09:05 (7 years ago) parentbf2eb4f
3 files changed+20−8
MANUAL.txt+7−6 src/Text/Pandoc/Readers/Markdown.hs+6−2 test/command/5878.md+7
MANUAL.txt+7−6
@@ -4042,12 +4042,13 @@ text by `~` characters. Thus, for example,
40424042
40434043 H~2~O is a liquid. 2^10^ is 1024.
40444044
4045−If the superscripted or subscripted text contains spaces, these spaces
4046−must be escaped with backslashes. (This is to prevent accidental
4047−superscripting and subscripting through the ordinary use of `~` and `^`.)
4048−Thus, if you want the letter P with 'a cat' in subscripts, use
4049−`P~a\ cat~`, not `P~a cat~`.
4050−
4045+The text between `^...^` or `~...~` may not contain spaces or
4046+newlines. If the superscripted or subscripted text contains
4047+spaces, these spaces must be escaped with backslashes. (This is
4048+to prevent accidental superscripting and subscripting through
4049+the ordinary use of `~` and `^`, and also bad interactions with
4050+footnotes.) Thus, if you want the letter P with 'a cat' in
4051+subscripts, use `P~a\ cat~`, not `P~a cat~`.
40514052
40524053### Verbatim ###
40534054
src/Text/Pandoc/Readers/Markdown.hs+6−2
@@ -1700,13 +1700,17 @@ superscript :: PandocMonad m => MarkdownParser m (F Inlines)
17001700superscript = fmap B.superscript <$> try (do
17011701 guardEnabled Ext_superscript
17021702 char '^'
1703− mconcat <$> many1Till (notFollowedBy spaceChar >> inline) (char '^'))
1703+ mconcat <$> many1Till (do notFollowedBy spaceChar
1704+ notFollowedBy newline
1705+ inline) (char '^'))
17041706
17051707subscript :: PandocMonad m => MarkdownParser m (F Inlines)
17061708subscript = fmap B.subscript <$> try (do
17071709 guardEnabled Ext_subscript
17081710 char '~'
1709− mconcat <$> many1Till (notFollowedBy spaceChar >> inline) (char '~'))
1711+ mconcat <$> many1Till (do notFollowedBy spaceChar
1712+ notFollowedBy newline
1713+ inline) (char '~'))
17101714
17111715whitespace :: PandocMonad m => MarkdownParser m (F Inlines)
17121716whitespace = spaceChar >> return <$> (lb <|> regsp) <?> "whitespace"
test/command/5878.mdnew file+7
@@ -0,0 +1,7 @@
1+```
2+% pandoc -t native
3+Zozime^[],
4+Synésius^[]
5+^D
6+[Para [Str "Zozime",Note [Para []],Str ",",SoftBreak,Str "Syn\233sius",Note [Para []]]]
7+```