@@ -289,14 +289,14 @@ paragraph' end' = do
289
289
modify $ modifierInline .~ new
290
290
where
291
291
close (NoModifier b) = fail " No closing"
292
- close (OpenModifier cm i b) =
292
+ close (OpenModifier cm i b) =
293
293
case b of
294
294
(OpenModifier cd id bd) -> if c == cm then pure (OpenModifier cd (id <> f i) bd) else close (OpenModifier cd (id <> Text cm <> i) bd)
295
295
(NoModifier id ) -> if c == cm then pure (NoModifier (id <> f i)) else fail " No closing"
296
296
pushStack :: Text -> StateT InlineState p ()
297
297
pushStack c = do
298
298
s <- gets (view modifierInline)
299
- new <- case s of
299
+ new <- case s of
300
300
NoModifier i -> pure $ OpenModifier c mempty (NoModifier i)
301
301
stack@ (OpenModifier cm i b) ->
302
302
if not $ hasModifier c stack
@@ -337,8 +337,8 @@ paragraph' end' = do
337
337
where
338
338
follow =
339
339
singleSpace <|> newline
340
- <|> withNextChar
341
- (guard . flip S. member (punctuationSymbols <> attachedModifierSymbols))
340
+ <|> withNextChar
341
+ (guard . flip S. member (punctuationSymbols <> attachedModifierSymbols))
342
342
parseOpening c = do
343
343
P. try $ do
344
344
anyChar >> withNextChar (\ c -> guard $ isLetter c || S. member c specialSymbols)
@@ -374,17 +374,31 @@ paragraph' end' = do
374
374
modify (delimitedActive .~ False )
375
375
if S. member c (punctuationSymbols <> attachedModifierSymbols)
376
376
then
377
- ( do
378
- p <- lift anyChar <&> pack . (: [] )
379
- appendInlineToStack (Text p)
380
- withNextChar $ \ c -> parWhitespace c <|> attachedClosings c <|> attachedOpenings c <|> word c
377
+ ( P. try
378
+ ( do
379
+ guard (c == ' \\ ' )
380
+ a <- anyChar >> anyChar
381
+ guard (a > ' ' )
382
+ pure a
383
+ )
384
+ >>= \ x -> do
385
+ appendInlineToStack
386
+ (Text $ pack [x])
387
+ withNextChar $
388
+ \ c -> parWhitespace c <|> attachedClosings c <|> word c
381
389
)
390
+ <|> ( do
391
+ p <- lift anyChar <&> pack . (: [] )
392
+ appendInlineToStack (Text p)
393
+ withNextChar $ \ c -> parWhitespace c <|> attachedClosings c <|> attachedOpenings c <|> word c
394
+ )
382
395
else
383
396
( do
384
397
w <- P. takeWhile1P (Just " Word" ) (\ c -> c > ' ' && S. notMember c (punctuationSymbols <> attachedModifierSymbols))
385
398
appendInlineToStack (Text w)
386
399
withNextChar $ \ c -> parWhitespace c <|> attachedClosings c <|> word c
387
400
)
401
+
388
402
punctuationSymbols = S. fromList " ?!:;,.<>()[]{}'\" /#%&$£€-*\\ ~"
389
403
attachedModifierSymbols = S. fromList " */_-^,|`$="
390
404
@@ -396,7 +410,7 @@ paragraph' end' = do
396
410
intersectingModifier :: Char -> StateT InlineState p ()
397
411
intersectingModifier c1 = do
398
412
c2 <- followedBy $ anyChar >> anyChar
399
- case c1: [c2] of
413
+ case c1 : [c2] of
400
414
" :*" -> intersectingOpen " :*"
401
415
" :/" -> intersectingOpen " :/"
402
416
" :_" -> intersectingOpen " :_"
@@ -406,7 +420,6 @@ paragraph' end' = do
406
420
" :|" -> intersectingOpen " :|"
407
421
" :`" -> parseTextModifier (pure () ) " :`" Verbatim
408
422
" :$" -> parseTextModifier (pure () ) " :$" Math
409
-
410
423
" *:" -> intersectingClosed " :*" Bold
411
424
" /:" -> intersectingClosed " :/" Italic
412
425
" _:" -> intersectingClosed " :_" Underline
0 commit comments