Open jgm opened 4 years ago
One idea would be to add an Options data structure
data Options m =
Options{
optIncludeSourceRanges :: Bool,
optWarn :: Warning -> m (),
optAddToSourceMap :: Text -> SourceRange -> m ()
}
optWarn
would allow us to issue warnings for things like duplicate references in a flexible way (#48).
optAddToSourceMap
would allow us to construct source maps in a flexible way (#33).
Putting these in options may be more flexible than using typeclasses.
Defaults could be False
, \_ -> return ()
, and \_ _ -> return ()
.
We could use a reader monad transformer to make these available in block and inline parsers.
I don't really care how they get there as long as the option is there! We're really looking forward to having a source maps available for vim-pandoc
! We have a working prototype right now of a new syntax system using an external source map provided by pulldown-cmark which reports start and stop byte ranges. This is working great but we really need the full range of Pandoc extensions, not just CommonMark.
The option is there already (as well as the ability to create a source map). This was just an idea about an alternative way to put it there.
@alerque for a demo of the source map functionality, you can do commonmark --highlight -xall README.md
. This does syntax highlighting with all the extensions enabled. To see how this is done see the code for commonmark-cli.
Instead of handling it with typeclasses. This would allow simpler typeclasses: Html, Pandoc. It might also allow us to improve performance by avoiding the work of storing and computing ranges.