Skip to content

Commit

Permalink
Parse [^] as a link
Browse files Browse the repository at this point in the history
This is consistent with most other CommonMark parsers, even when
they have support for footnotes turned on.
  • Loading branch information
notriddle authored and jgm committed Oct 27, 2023
1 parent 8c326d8 commit db51141
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions commonmark-extensions/src/Commonmark/Extensions/Footnote.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import Data.Maybe (fromMaybe, mapMaybe)
import Data.Dynamic
import Data.Tree
import Text.Parsec
import Data.Text (Text)
import Data.Text (Text, empty)
import qualified Data.Text as T
import qualified Data.Map as M

Expand Down Expand Up @@ -103,7 +103,7 @@ pFootnoteLabel :: Monad m => ParsecT [Tok] u m Text
pFootnoteLabel = try $ do
lab <- pLinkLabel
case T.uncons lab of
Just ('^', t') -> return $! t'
Just ('^', t') | t' /= Data.Text.empty -> return $! t'
_ -> mzero

pFootnoteRef :: (Monad m, Typeable m, Typeable a,
Expand Down
10 changes: 10 additions & 0 deletions commonmark-extensions/test/footnotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,13 @@ Footnote containing a list[^list]
</div>
</section>
````````````````````````````````

Footnote labels cannot be empty.

```````````````````````````````` example
Test [^] link
[^]: https://haskell.org
.
<p>Test <a href="https://haskell.org">^</a> link</p>
````````````````````````````````

0 comments on commit db51141

Please sign in to comment.