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.
This commit is contained in:
parent
bf2eb4f288
commit
741b1f7fb4
3 changed files with 20 additions and 8 deletions
13
MANUAL.txt
13
MANUAL.txt
|
@ -4042,12 +4042,13 @@ text by `~` characters. Thus, for example,
|
||||||
|
|
||||||
H~2~O is a liquid. 2^10^ is 1024.
|
H~2~O is a liquid. 2^10^ is 1024.
|
||||||
|
|
||||||
If the superscripted or subscripted text contains spaces, these spaces
|
The text between `^...^` or `~...~` may not contain spaces or
|
||||||
must be escaped with backslashes. (This is to prevent accidental
|
newlines. If the superscripted or subscripted text contains
|
||||||
superscripting and subscripting through the ordinary use of `~` and `^`.)
|
spaces, these spaces must be escaped with backslashes. (This is
|
||||||
Thus, if you want the letter P with 'a cat' in subscripts, use
|
to prevent accidental superscripting and subscripting through
|
||||||
`P~a\ cat~`, not `P~a cat~`.
|
the ordinary use of `~` and `^`, and also bad interactions with
|
||||||
|
footnotes.) Thus, if you want the letter P with 'a cat' in
|
||||||
|
subscripts, use `P~a\ cat~`, not `P~a cat~`.
|
||||||
|
|
||||||
### Verbatim ###
|
### Verbatim ###
|
||||||
|
|
||||||
|
|
|
@ -1700,13 +1700,17 @@ superscript :: PandocMonad m => MarkdownParser m (F Inlines)
|
||||||
superscript = fmap B.superscript <$> try (do
|
superscript = fmap B.superscript <$> try (do
|
||||||
guardEnabled Ext_superscript
|
guardEnabled Ext_superscript
|
||||||
char '^'
|
char '^'
|
||||||
mconcat <$> many1Till (notFollowedBy spaceChar >> inline) (char '^'))
|
mconcat <$> many1Till (do notFollowedBy spaceChar
|
||||||
|
notFollowedBy newline
|
||||||
|
inline) (char '^'))
|
||||||
|
|
||||||
subscript :: PandocMonad m => MarkdownParser m (F Inlines)
|
subscript :: PandocMonad m => MarkdownParser m (F Inlines)
|
||||||
subscript = fmap B.subscript <$> try (do
|
subscript = fmap B.subscript <$> try (do
|
||||||
guardEnabled Ext_subscript
|
guardEnabled Ext_subscript
|
||||||
char '~'
|
char '~'
|
||||||
mconcat <$> many1Till (notFollowedBy spaceChar >> inline) (char '~'))
|
mconcat <$> many1Till (do notFollowedBy spaceChar
|
||||||
|
notFollowedBy newline
|
||||||
|
inline) (char '~'))
|
||||||
|
|
||||||
whitespace :: PandocMonad m => MarkdownParser m (F Inlines)
|
whitespace :: PandocMonad m => MarkdownParser m (F Inlines)
|
||||||
whitespace = spaceChar >> return <$> (lb <|> regsp) <?> "whitespace"
|
whitespace = spaceChar >> return <$> (lb <|> regsp) <?> "whitespace"
|
||||||
|
|
7
test/command/5878.md
Normal file
7
test/command/5878.md
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
```
|
||||||
|
% pandoc -t native
|
||||||
|
Zozime^[],
|
||||||
|
Synésius^[]
|
||||||
|
^D
|
||||||
|
[Para [Str "Zozime",Note [Para []],Str ",",SoftBreak,Str "Syn\233sius",Note [Para []]]]
|
||||||
|
```
|
Loading…
Reference in a new issue