mirror of
https://github.com/russross/blackfriday.git
synced 2024-03-22 13:40:34 +08:00
Rename public constants to idiomatic Go
This commit is contained in:
parent
0b647d0506
commit
06515e9125
39
html.go
39
html.go
|
@ -23,26 +23,29 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type HtmlFlags int
|
||||||
|
|
||||||
// Html renderer configuration options.
|
// Html renderer configuration options.
|
||||||
const (
|
const (
|
||||||
HTML_SKIP_HTML = 1 << iota // skip preformatted HTML blocks
|
HtmlFlagsNone HtmlFlags = 0
|
||||||
HTML_SKIP_STYLE // skip embedded <style> elements
|
SkipHTML HtmlFlags = 1 << iota // Skip preformatted HTML blocks
|
||||||
HTML_SKIP_IMAGES // skip embedded images
|
SkipStyle // Skip embedded <style> elements
|
||||||
HTML_SKIP_LINKS // skip all links
|
SkipImages // Skip embedded images
|
||||||
HTML_SAFELINK // only link to trusted protocols
|
SkipLinks // Skip all links
|
||||||
HTML_NOFOLLOW_LINKS // only link with rel="nofollow"
|
Safelink // Only link to trusted protocols
|
||||||
HTML_NOREFERRER_LINKS // only link with rel="noreferrer"
|
NofollowLinks // Only link with rel="nofollow"
|
||||||
HTML_HREF_TARGET_BLANK // add a blank target
|
NoreferrerLinks // Only link with rel="noreferrer"
|
||||||
HTML_TOC // generate a table of contents
|
HrefTargetBlank // Add a blank target
|
||||||
HTML_OMIT_CONTENTS // skip the main contents (for a standalone table of contents)
|
Toc // Generate a table of contents
|
||||||
HTML_COMPLETE_PAGE // generate a complete HTML page
|
OmitContents // Skip the main contents (for a standalone table of contents)
|
||||||
HTML_USE_XHTML // generate XHTML output instead of HTML
|
CompletePage // Generate a complete HTML page
|
||||||
HTML_USE_SMARTYPANTS // enable smart punctuation substitutions
|
UseXHTML // Generate XHTML output instead of HTML
|
||||||
HTML_SMARTYPANTS_FRACTIONS // enable smart fractions (with HTML_USE_SMARTYPANTS)
|
UseSmartypants // Enable smart punctuation substitutions
|
||||||
HTML_SMARTYPANTS_DASHES // enable smart dashes (with HTML_USE_SMARTYPANTS)
|
SmartypantsFractions // Enable smart fractions (with UseSmartypants)
|
||||||
HTML_SMARTYPANTS_LATEX_DASHES // enable LaTeX-style dashes (with HTML_USE_SMARTYPANTS and HTML_SMARTYPANTS_DASHES)
|
SmartypantsDashes // Enable smart dashes (with UseSmartypants)
|
||||||
HTML_SMARTYPANTS_ANGLED_QUOTES // enable angled double quotes (with HTML_USE_SMARTYPANTS) for double quotes rendering
|
SmartypantsLatexDashes // Enable LaTeX-style dashes (with UseSmartypants)
|
||||||
HTML_FOOTNOTE_RETURN_LINKS // generate a link at the end of a footnote to return to the source
|
SmartypantsAngledQuotes // Enable angled double quotes (with UseSmartypants) for double quotes rendering
|
||||||
|
FootnoteReturnLinks // Generate a link at the end of a footnote to return to the source
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
93
markdown.go
93
markdown.go
|
@ -27,79 +27,78 @@ import (
|
||||||
|
|
||||||
const VERSION = "1.4"
|
const VERSION = "1.4"
|
||||||
|
|
||||||
|
type Extensions int
|
||||||
|
|
||||||
// These are the supported markdown parsing extensions.
|
// These are the supported markdown parsing extensions.
|
||||||
// OR these values together to select multiple extensions.
|
// OR these values together to select multiple extensions.
|
||||||
const (
|
const (
|
||||||
EXTENSION_NO_INTRA_EMPHASIS = 1 << iota // ignore emphasis markers inside words
|
NoExtensions Extensions = 0
|
||||||
EXTENSION_TABLES // render tables
|
NoIntraEmphasis Extensions = 1 << iota // Ignore emphasis markers inside words
|
||||||
EXTENSION_FENCED_CODE // render fenced code blocks
|
Tables // Render tables
|
||||||
EXTENSION_AUTOLINK // detect embedded URLs that are not explicitly marked
|
FencedCode // Render fenced code blocks
|
||||||
EXTENSION_STRIKETHROUGH // strikethrough text using ~~test~~
|
Autolink // Detect embedded URLs that are not explicitly marked
|
||||||
EXTENSION_LAX_HTML_BLOCKS // loosen up HTML block parsing rules
|
Strikethrough // Strikethrough text using ~~test~~
|
||||||
EXTENSION_SPACE_HEADERS // be strict about prefix header rules
|
LaxHTMLBlocks // Loosen up HTML block parsing rules
|
||||||
EXTENSION_HARD_LINE_BREAK // translate newlines into line breaks
|
SpaceHeaders // Be strict about prefix header rules
|
||||||
EXTENSION_TAB_SIZE_EIGHT // expand tabs to eight spaces instead of four
|
HardLineBreak // Translate newlines into line breaks
|
||||||
EXTENSION_FOOTNOTES // Pandoc-style footnotes
|
TabSizeEight // Expand tabs to eight spaces instead of four
|
||||||
EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK // No need to insert an empty line to start a (code, quote, ordered list, unordered list) block
|
Footnotes // Pandoc-style footnotes
|
||||||
EXTENSION_HEADER_IDS // specify header IDs with {#id}
|
NoEmptyLineBeforeBlock // No need to insert an empty line to start a (code, quote, ordered list, unordered list) block
|
||||||
EXTENSION_TITLEBLOCK // Titleblock ala pandoc
|
HeaderIDs // specify header IDs with {#id}
|
||||||
EXTENSION_AUTO_HEADER_IDS // Create the header ID from the text
|
Titleblock // Titleblock ala pandoc
|
||||||
EXTENSION_BACKSLASH_LINE_BREAK // translate trailing backslashes into line breaks
|
AutoHeaderIDs // Create the header ID from the text
|
||||||
EXTENSION_DEFINITION_LISTS // render definition lists
|
BackslashLineBreak // Translate trailing backslashes into line breaks
|
||||||
|
DefinitionLists // Render definition lists
|
||||||
|
|
||||||
commonHtmlFlags = 0 |
|
commonHtmlFlags HtmlFlags = UseXHTML | UseSmartypants |
|
||||||
HTML_USE_XHTML |
|
SmartypantsFractions | SmartypantsDashes | SmartypantsLatexDashes
|
||||||
HTML_USE_SMARTYPANTS |
|
|
||||||
HTML_SMARTYPANTS_FRACTIONS |
|
|
||||||
HTML_SMARTYPANTS_DASHES |
|
|
||||||
HTML_SMARTYPANTS_LATEX_DASHES
|
|
||||||
|
|
||||||
commonExtensions = 0 |
|
commonExtensions Extensions = NoIntraEmphasis | Tables | FencedCode |
|
||||||
EXTENSION_NO_INTRA_EMPHASIS |
|
Autolink | Strikethrough | SpaceHeaders | HeaderIDs |
|
||||||
EXTENSION_TABLES |
|
BackslashLineBreak | DefinitionLists
|
||||||
EXTENSION_FENCED_CODE |
|
|
||||||
EXTENSION_AUTOLINK |
|
|
||||||
EXTENSION_STRIKETHROUGH |
|
|
||||||
EXTENSION_SPACE_HEADERS |
|
|
||||||
EXTENSION_HEADER_IDS |
|
|
||||||
EXTENSION_BACKSLASH_LINE_BREAK |
|
|
||||||
EXTENSION_DEFINITION_LISTS
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type LinkType int
|
||||||
|
|
||||||
// These are the possible flag values for the link renderer.
|
// These are the possible flag values for the link renderer.
|
||||||
// Only a single one of these values will be used; they are not ORed together.
|
// Only a single one of these values will be used; they are not ORed together.
|
||||||
// These are mostly of interest if you are writing a new output format.
|
// These are mostly of interest if you are writing a new output format.
|
||||||
const (
|
const (
|
||||||
LINK_TYPE_NOT_AUTOLINK = iota
|
LinkTypeNotAutolink LinkType = iota
|
||||||
LINK_TYPE_NORMAL
|
LinkTypeNormal
|
||||||
LINK_TYPE_EMAIL
|
LinkTypeEmail
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type ListType int
|
||||||
|
|
||||||
// These are the possible flag values for the ListItem renderer.
|
// These are the possible flag values for the ListItem renderer.
|
||||||
// Multiple flag values may be ORed together.
|
// Multiple flag values may be ORed together.
|
||||||
// These are mostly of interest if you are writing a new output format.
|
// These are mostly of interest if you are writing a new output format.
|
||||||
const (
|
const (
|
||||||
LIST_TYPE_ORDERED = 1 << iota
|
ListTypeOrdered ListType = 1 << iota
|
||||||
LIST_TYPE_DEFINITION
|
ListTypeDefinition
|
||||||
LIST_TYPE_TERM
|
ListTypeTerm
|
||||||
LIST_ITEM_CONTAINS_BLOCK
|
|
||||||
LIST_ITEM_BEGINNING_OF_LIST
|
ListItemContainsBlock
|
||||||
LIST_ITEM_END_OF_LIST
|
ListItemBeginningOfList
|
||||||
|
ListItemEndOfList
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type TableFlags int
|
||||||
|
|
||||||
// These are the possible flag values for the table cell renderer.
|
// These are the possible flag values for the table cell renderer.
|
||||||
// Only a single one of these values will be used; they are not ORed together.
|
// Only a single one of these values will be used; they are not ORed together.
|
||||||
// These are mostly of interest if you are writing a new output format.
|
// These are mostly of interest if you are writing a new output format.
|
||||||
const (
|
const (
|
||||||
TABLE_ALIGNMENT_LEFT = 1 << iota
|
TableAlignmentLeft = 1 << iota
|
||||||
TABLE_ALIGNMENT_RIGHT
|
TableAlignmentRight
|
||||||
TABLE_ALIGNMENT_CENTER = (TABLE_ALIGNMENT_LEFT | TABLE_ALIGNMENT_RIGHT)
|
TableAlignmentCenter = (TableAlignmentLeft | TableAlignmentRight)
|
||||||
)
|
)
|
||||||
|
|
||||||
// The size of a tab stop.
|
// The size of a tab stop.
|
||||||
const (
|
const (
|
||||||
TAB_SIZE_DEFAULT = 4
|
TabSizeDefault = 4
|
||||||
TAB_SIZE_EIGHT = 8
|
TabSizeDouble = 8
|
||||||
)
|
)
|
||||||
|
|
||||||
// blockTags is a set of tags that are recognized as HTML block tags.
|
// blockTags is a set of tags that are recognized as HTML block tags.
|
||||||
|
@ -212,7 +211,7 @@ type parser struct {
|
||||||
refOverride ReferenceOverrideFunc
|
refOverride ReferenceOverrideFunc
|
||||||
refs map[string]*reference
|
refs map[string]*reference
|
||||||
inlineCallback [256]inlineParser
|
inlineCallback [256]inlineParser
|
||||||
flags int
|
flags int // TODO: int ==> Extensions
|
||||||
nesting int
|
nesting int
|
||||||
maxNesting int
|
maxNesting int
|
||||||
insideLink bool
|
insideLink bool
|
||||||
|
|
Loading…
Reference in New Issue
Block a user