1{-# LANGUAGE DeriveDataTypeable #-}
2{-# LANGUAGE DeriveGeneric #-}
4Copyright (C) 2012-2016 John MacFarlane <jgm@berkeley.edu>
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 Module : Text.Pandoc.Extensions
23 Copyright : Copyright (C) 2012-2016 John MacFarlane
24 License : GNU GPL, version 2 or above
26 Maintainer : John MacFarlane <jgm@berkeley.edu>
28 Portability : portable
30Data structures and functions for representing markup extensions.
32module Text.Pandoc.Extensions ( Extension(..)
42 , phpMarkdownExtraExtensions
43 , githubMarkdownExtensions
44 , multimarkdownExtensions )
46import Data.Bits (clearBit, setBit, testBit)
47import Data.Data (Data)
48import Data.Typeable (Typeable)
49import GHC.Generics (Generic)
51newtype Extensions = Extensions Integer
52 deriving (Show, Read, Eq, Ord, Data, Typeable, Generic)
54extensionsFromList :: [Extension] -> Extensions
55extensionsFromList = foldr enableExtension emptyExtensions
57emptyExtensions :: Extensions
58emptyExtensions = Extensions 0
60extensionEnabled :: Extension -> Extensions -> Bool
61extensionEnabled x (Extensions exts) = testBit exts (fromEnum x)
63enableExtension :: Extension -> Extensions -> Extensions
64enableExtension x (Extensions exts) = Extensions (setBit exts (fromEnum x))
66disableExtension :: Extension -> Extensions -> Extensions
67disableExtension x (Extensions exts) = Extensions (clearBit exts (fromEnum x))
69-- | Individually selectable syntax extensions.
71 Ext_footnotes -- ^ Pandoc/PHP/MMD style footnotes
72 | Ext_inline_notes -- ^ Pandoc-style inline notes
73 | Ext_pandoc_title_block -- ^ Pandoc title block
74 | Ext_yaml_metadata_block -- ^ YAML metadata block
75 | Ext_mmd_title_block -- ^ Multimarkdown metadata block
76 | Ext_table_captions -- ^ Pandoc-style table captions
77 | Ext_implicit_figures -- ^ A paragraph with just an image is a figure
78 | Ext_simple_tables -- ^ Pandoc-style simple tables
79 | Ext_multiline_tables -- ^ Pandoc-style multiline tables
80 | Ext_grid_tables -- ^ Grid tables (pandoc, reST)
81 | Ext_pipe_tables -- ^ Pipe tables (as in PHP markdown extra)
82 | Ext_citations -- ^ Pandoc/citeproc citations
83 | Ext_raw_tex -- ^ Allow raw TeX (other than math)
84 | Ext_raw_html -- ^ Allow raw HTML
85 | Ext_tex_math_dollars -- ^ TeX math between $..$ or $$..$$
86 | Ext_tex_math_single_backslash -- ^ TeX math btw \(..\) \[..\]
87 | Ext_tex_math_double_backslash -- ^ TeX math btw \\(..\\) \\[..\\]
88 | Ext_latex_macros -- ^ Parse LaTeX macro definitions (for math only)
89 | Ext_fenced_code_blocks -- ^ Parse fenced code blocks
90 | Ext_fenced_code_attributes -- ^ Allow attributes on fenced code blocks
91 | Ext_backtick_code_blocks -- ^ GitHub style ``` code blocks
92 | Ext_inline_code_attributes -- ^ Allow attributes on inline code
93 | Ext_markdown_in_html_blocks -- ^ Interpret as markdown inside HTML blocks
94 | Ext_native_divs -- ^ Use Div blocks for contents of <div> tags
95 | Ext_native_spans -- ^ Use Span inlines for contents of <span>
96 | Ext_bracketed_spans -- ^ Bracketed spans with attributes
97 | Ext_markdown_attribute -- ^ Interpret text inside HTML as markdown
98 -- iff container has attribute 'markdown'
99 | Ext_escaped_line_breaks -- ^ Treat a backslash at EOL as linebreak
100 | Ext_link_attributes -- ^ link and image attributes
101 | Ext_mmd_link_attributes -- ^ MMD style reference link attributes
102 | Ext_autolink_bare_uris -- ^ Make all absolute URIs into links
103 | Ext_fancy_lists -- ^ Enable fancy list numbers and delimiters
104 | Ext_lists_without_preceding_blankline -- ^ Allow lists without preceding blank
105 | Ext_startnum -- ^ Make start number of ordered list significant
106 | Ext_definition_lists -- ^ Definition lists as in pandoc, mmd, php
107 | Ext_compact_definition_lists -- ^ Definition lists without
108 -- space between items, and disallow laziness
109 | Ext_example_lists -- ^ Markdown-style numbered examples
110 | Ext_all_symbols_escapable -- ^ Make all non-alphanumerics escapable
111 | Ext_angle_brackets_escapable -- ^ Make < and > escapable
112 | Ext_intraword_underscores -- ^ Treat underscore inside word as literal
113 | Ext_blank_before_blockquote -- ^ Require blank line before a blockquote
114 | Ext_blank_before_header -- ^ Require blank line before a header
115 | Ext_strikeout -- ^ Strikeout using ~~this~~ syntax
116 | Ext_superscript -- ^ Superscript using ^this^ syntax
117 | Ext_subscript -- ^ Subscript using ~this~ syntax
118 | Ext_hard_line_breaks -- ^ All newlines become hard line breaks
119 | Ext_ignore_line_breaks -- ^ Newlines in paragraphs are ignored
120 | Ext_east_asian_line_breaks -- ^ Newlines in paragraphs are ignored between
121 -- East Asian wide characters
122 | Ext_literate_haskell -- ^ Enable literate Haskell conventions
123 | Ext_abbreviations -- ^ PHP markdown extra abbreviation definitions
124 | Ext_emoji -- ^ Support emoji like :smile:
125 | Ext_auto_identifiers -- ^ Automatic identifiers for headers
126 | Ext_ascii_identifiers -- ^ ascii-only identifiers for headers
127 | Ext_header_attributes -- ^ Explicit header attributes {#id .class k=v}
128 | Ext_mmd_header_identifiers -- ^ Multimarkdown style header identifiers [myid]
129 | Ext_implicit_header_references -- ^ Implicit reference links for headers
130 | Ext_line_blocks -- ^ RST style line blocks
131 | Ext_epub_html_exts -- ^ Recognise the EPUB extended version of HTML
132 | Ext_shortcut_reference_links -- ^ Shortcut reference links
133 | Ext_smart -- ^ "Smart" quotes, apostrophes, ellipses, dashes
134 | Ext_old_dashes -- ^ -- = em, - before number = en
135 deriving (Show, Read, Enum, Eq, Ord, Bounded, Data, Typeable, Generic)
137pandocExtensions :: Extensions
138pandocExtensions = extensionsFromList
141 , Ext_pandoc_title_block
142 , Ext_yaml_metadata_block
144 , Ext_implicit_figures
146 , Ext_multiline_tables
152 , Ext_tex_math_dollars
154 , Ext_fenced_code_blocks
155 , Ext_fenced_code_attributes
156 , Ext_backtick_code_blocks
157 , Ext_inline_code_attributes
158 , Ext_markdown_in_html_blocks
161 , Ext_bracketed_spans
162 , Ext_escaped_line_breaks
165 , Ext_definition_lists
167 , Ext_all_symbols_escapable
168 , Ext_intraword_underscores
169 , Ext_blank_before_blockquote
170 , Ext_blank_before_header
174 , Ext_auto_identifiers
175 , Ext_header_attributes
176 , Ext_link_attributes
177 , Ext_implicit_header_references
179 , Ext_shortcut_reference_links
183plainExtensions :: Extensions
184plainExtensions = extensionsFromList
186 , Ext_implicit_figures
188 , Ext_multiline_tables
193 , Ext_definition_lists
195 , Ext_intraword_underscores
196 , Ext_blank_before_blockquote
197 , Ext_blank_before_header
201phpMarkdownExtraExtensions :: Extensions
202phpMarkdownExtraExtensions = extensionsFromList
206 , Ext_markdown_attribute
207 , Ext_fenced_code_blocks
208 , Ext_definition_lists
209 , Ext_intraword_underscores
210 , Ext_header_attributes
211 , Ext_link_attributes
213 , Ext_shortcut_reference_links
216githubMarkdownExtensions :: Extensions
217githubMarkdownExtensions = extensionsFromList
218 [ Ext_angle_brackets_escapable
221 , Ext_fenced_code_blocks
222 , Ext_auto_identifiers
223 , Ext_ascii_identifiers
224 , Ext_backtick_code_blocks
225 , Ext_autolink_bare_uris
226 , Ext_intraword_underscores
228 , Ext_hard_line_breaks
230 , Ext_lists_without_preceding_blankline
231 , Ext_shortcut_reference_links
234multimarkdownExtensions :: Extensions
235multimarkdownExtensions = extensionsFromList
238 , Ext_markdown_attribute
239 , Ext_mmd_link_attributes
241 -- Note: MMD's raw TeX syntax requires raw TeX to be
242 -- enclosed in HTML comment
243 , Ext_tex_math_double_backslash
244 , Ext_intraword_underscores
245 , Ext_mmd_title_block
247 , Ext_definition_lists
248 , Ext_all_symbols_escapable
249 , Ext_implicit_header_references
250 , Ext_shortcut_reference_links
251 , Ext_auto_identifiers
252 , Ext_mmd_header_identifiers
253 , Ext_implicit_figures
254 -- Note: MMD's syntax for superscripts and subscripts
255 -- is a bit more permissive than pandoc's, allowing
256 -- e^2 and a~1 instead of e^2^ and a~1~, so even with
257 -- these options we don't have full support for MMD
258 -- superscripts and subscripts, but there's no reason
259 -- not to include these:
264strictExtensions :: Extensions
265strictExtensions = extensionsFromList
267 , Ext_shortcut_reference_links
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list