Shared: Changed stringify so it ignores notes.
Also documented this in README.
This commit is contained in:
parent
399c75da44
commit
89a7703260
2 changed files with 6 additions and 1 deletions
1
README
1
README
|
@ -980,6 +980,7 @@ automatically assigned a unique identifier based on the header text.
|
||||||
To derive the identifier from the header text,
|
To derive the identifier from the header text,
|
||||||
|
|
||||||
- Remove all formatting, links, etc.
|
- Remove all formatting, links, etc.
|
||||||
|
- Remove all footnotes.
|
||||||
- Remove all punctuation, except underscores, hyphens, and periods.
|
- Remove all punctuation, except underscores, hyphens, and periods.
|
||||||
- Replace all spaces and newlines with hyphens.
|
- Replace all spaces and newlines with hyphens.
|
||||||
- Convert all alphabetic characters to lowercase.
|
- Convert all alphabetic characters to lowercase.
|
||||||
|
|
|
@ -384,8 +384,10 @@ consolidateInlines (x : xs) = x : consolidateInlines xs
|
||||||
consolidateInlines [] = []
|
consolidateInlines [] = []
|
||||||
|
|
||||||
-- | Convert list of inlines to a string with formatting removed.
|
-- | Convert list of inlines to a string with formatting removed.
|
||||||
|
-- Footnotes are skipped (since we don't want their contents in link
|
||||||
|
-- labels).
|
||||||
stringify :: [Inline] -> String
|
stringify :: [Inline] -> String
|
||||||
stringify = query go
|
stringify = query go . walk deNote
|
||||||
where go :: Inline -> [Char]
|
where go :: Inline -> [Char]
|
||||||
go Space = " "
|
go Space = " "
|
||||||
go (Str x) = x
|
go (Str x) = x
|
||||||
|
@ -393,6 +395,8 @@ stringify = query go
|
||||||
go (Math _ x) = x
|
go (Math _ x) = x
|
||||||
go LineBreak = " "
|
go LineBreak = " "
|
||||||
go _ = ""
|
go _ = ""
|
||||||
|
deNote (Note _) = Str ""
|
||||||
|
deNote x = x
|
||||||
|
|
||||||
-- | Change final list item from @Para@ to @Plain@ if the list contains
|
-- | Change final list item from @Para@ to @Plain@ if the list contains
|
||||||
-- no other @Para@ blocks.
|
-- no other @Para@ blocks.
|
||||||
|
|
Loading…
Add table
Reference in a new issue