gofmt
This commit is contained in:
parent
5bccaab30c
commit
4626c2b169
@ -2,10 +2,10 @@ package markdown
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"strings"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ func (w *htmlOut) s(s string) *htmlOut {
|
|||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
|
|
||||||
/* print string, escaping for HTML
|
/* print string, escaping for HTML
|
||||||
* If obfuscate selected, convert characters to hex or decimal entities at random
|
* If obfuscate selected, convert characters to hex or decimal entities at random
|
||||||
*/
|
*/
|
||||||
func (w *htmlOut) str(s string) *htmlOut {
|
func (w *htmlOut) str(s string) *htmlOut {
|
||||||
|
118
parser.leg
118
parser.leg
@ -23,8 +23,8 @@ package markdown
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"strings"
|
|
||||||
"log"
|
"log"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -33,29 +33,29 @@ const (
|
|||||||
|
|
||||||
// Semantic value of a parsing action.
|
// Semantic value of a parsing action.
|
||||||
type element struct {
|
type element struct {
|
||||||
key int
|
key int
|
||||||
contents
|
contents
|
||||||
children *element
|
children *element
|
||||||
next *element
|
next *element
|
||||||
}
|
}
|
||||||
|
|
||||||
// Information (label, URL and title) for a link.
|
// Information (label, URL and title) for a link.
|
||||||
type link struct {
|
type link struct {
|
||||||
label *element
|
label *element
|
||||||
url string
|
url string
|
||||||
title string
|
title string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Union for contents of an Element (string, list, or link).
|
// Union for contents of an Element (string, list, or link).
|
||||||
type contents struct {
|
type contents struct {
|
||||||
str string
|
str string
|
||||||
*link
|
*link
|
||||||
}
|
}
|
||||||
|
|
||||||
// Types of semantic values returned by parsers.
|
// Types of semantic values returned by parsers.
|
||||||
const (
|
const (
|
||||||
LIST = iota /* A generic list of values. For ordered and bullet lists, see below. */
|
LIST = iota /* A generic list of values. For ordered and bullet lists, see below. */
|
||||||
RAW /* Raw markdown to be processed further */
|
RAW /* Raw markdown to be processed further */
|
||||||
SPACE
|
SPACE
|
||||||
LINEBREAK
|
LINEBREAK
|
||||||
ELLIPSIS
|
ELLIPSIS
|
||||||
@ -76,7 +76,7 @@ const (
|
|||||||
LISTITEM
|
LISTITEM
|
||||||
BULLETLIST
|
BULLETLIST
|
||||||
ORDEREDLIST
|
ORDEREDLIST
|
||||||
H1 /* Code assumes that H1..6 are in order. */
|
H1 /* Code assumes that H1..6 are in order. */
|
||||||
H2
|
H2
|
||||||
H3
|
H3
|
||||||
H4
|
H4
|
||||||
@ -95,11 +95,11 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type state struct {
|
type state struct {
|
||||||
extension Extensions
|
extension Extensions
|
||||||
heap elemHeap
|
heap elemHeap
|
||||||
tree *element /* Results of parse. */
|
tree *element /* Results of parse. */
|
||||||
references *element /* List of link references found. */
|
references *element /* List of link references found. */
|
||||||
notes *element /* List of footnotes found. */
|
notes *element /* List of footnotes found. */
|
||||||
}
|
}
|
||||||
|
|
||||||
%}
|
%}
|
||||||
@ -854,12 +854,10 @@ DefMarker = &{ p.extension.Dlists } Defmark
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* List manipulation functions
|
* List manipulation functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/* cons - cons an element onto a list, returning pointer to new head
|
/* cons - cons an element onto a list, returning pointer to new head
|
||||||
*/
|
*/
|
||||||
func cons(new, list *element) *element {
|
func cons(new, list *element) *element {
|
||||||
@ -878,14 +876,12 @@ func reverse(list *element) (new *element) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Auxiliary functions for parsing actions.
|
* Auxiliary functions for parsing actions.
|
||||||
* These make it easier to build up data structures (including lists)
|
* These make it easier to build up data structures (including lists)
|
||||||
* in the parsing actions.
|
* in the parsing actions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/* p.mkElem - generic constructor for element
|
/* p.mkElem - generic constructor for element
|
||||||
*/
|
*/
|
||||||
func (p *yyParser) mkElem(key int) *element {
|
func (p *yyParser) mkElem(key int) *element {
|
||||||
@ -943,7 +939,6 @@ func (p *yyParser) mkLink(label *element, url, title string) (el *element) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* match_inlines - returns true if inline lists match (case-insensitive...)
|
/* match_inlines - returns true if inline lists match (case-insensitive...)
|
||||||
*/
|
*/
|
||||||
func match_inlines(l1, l2 *element) bool {
|
func match_inlines(l1, l2 *element) bool {
|
||||||
@ -963,17 +958,16 @@ func match_inlines(l1, l2 *element) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
case LINK, IMAGE:
|
case LINK, IMAGE:
|
||||||
return false /* No links or images within links */
|
return false /* No links or images within links */
|
||||||
default:
|
default:
|
||||||
log.Fatalf("match_inlines encountered unknown key = %d\n", l1.key)
|
log.Fatalf("match_inlines encountered unknown key = %d\n", l1.key)
|
||||||
}
|
}
|
||||||
l1 = l1.next
|
l1 = l1.next
|
||||||
l2 = l2.next
|
l2 = l2.next
|
||||||
}
|
}
|
||||||
return l1 == nil && l2 == nil /* return true if both lists exhausted */
|
return l1 == nil && l2 == nil /* return true if both lists exhausted */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* find_reference - return true if link found in references matching label.
|
/* find_reference - return true if link found in references matching label.
|
||||||
* 'link' is modified with the matching url and title.
|
* 'link' is modified with the matching url and title.
|
||||||
*/
|
*/
|
||||||
@ -987,7 +981,6 @@ func (p *yyParser) findReference(label *element) (*link, bool) {
|
|||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* find_note - return true if note found in notes matching label.
|
/* find_note - return true if note found in notes matching label.
|
||||||
* if found, 'result' is set to point to matched note.
|
* if found, 'result' is set to point to matched note.
|
||||||
*/
|
*/
|
||||||
@ -1000,7 +993,6 @@ func (p *yyParser) find_note(label string) (*element, bool) {
|
|||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* print tree of elements, for debugging only.
|
/* print tree of elements, for debugging only.
|
||||||
*/
|
*/
|
||||||
func print_tree(w io.Writer, elt *element, indent int) {
|
func print_tree(w io.Writer, elt *element, indent int) {
|
||||||
@ -1027,41 +1019,41 @@ func print_tree(w io.Writer, elt *element, indent int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var keynames = [numVAL]string{
|
var keynames = [numVAL]string{
|
||||||
LIST: "LIST",
|
LIST: "LIST",
|
||||||
RAW: "RAW",
|
RAW: "RAW",
|
||||||
SPACE: "SPACE",
|
SPACE: "SPACE",
|
||||||
LINEBREAK: "LINEBREAK",
|
LINEBREAK: "LINEBREAK",
|
||||||
ELLIPSIS: "ELLIPSIS",
|
ELLIPSIS: "ELLIPSIS",
|
||||||
EMDASH: "EMDASH",
|
EMDASH: "EMDASH",
|
||||||
ENDASH: "ENDASH",
|
ENDASH: "ENDASH",
|
||||||
APOSTROPHE: "APOSTROPHE",
|
APOSTROPHE: "APOSTROPHE",
|
||||||
SINGLEQUOTED: "SINGLEQUOTED",
|
SINGLEQUOTED: "SINGLEQUOTED",
|
||||||
DOUBLEQUOTED: "DOUBLEQUOTED",
|
DOUBLEQUOTED: "DOUBLEQUOTED",
|
||||||
STR: "STR",
|
STR: "STR",
|
||||||
LINK: "LINK",
|
LINK: "LINK",
|
||||||
IMAGE: "IMAGE",
|
IMAGE: "IMAGE",
|
||||||
CODE: "CODE",
|
CODE: "CODE",
|
||||||
HTML: "HTML",
|
HTML: "HTML",
|
||||||
EMPH: "EMPH",
|
EMPH: "EMPH",
|
||||||
STRONG: "STRONG",
|
STRONG: "STRONG",
|
||||||
PLAIN: "PLAIN",
|
PLAIN: "PLAIN",
|
||||||
PARA: "PARA",
|
PARA: "PARA",
|
||||||
LISTITEM: "LISTITEM",
|
LISTITEM: "LISTITEM",
|
||||||
BULLETLIST: "BULLETLIST",
|
BULLETLIST: "BULLETLIST",
|
||||||
ORDEREDLIST: "ORDEREDLIST",
|
ORDEREDLIST: "ORDEREDLIST",
|
||||||
H1: "H1",
|
H1: "H1",
|
||||||
H2: "H2",
|
H2: "H2",
|
||||||
H3: "H3",
|
H3: "H3",
|
||||||
H4: "H4",
|
H4: "H4",
|
||||||
H5: "H5",
|
H5: "H5",
|
||||||
H6: "H6",
|
H6: "H6",
|
||||||
BLOCKQUOTE: "BLOCKQUOTE",
|
BLOCKQUOTE: "BLOCKQUOTE",
|
||||||
VERBATIM: "VERBATIM",
|
VERBATIM: "VERBATIM",
|
||||||
HTMLBLOCK: "HTMLBLOCK",
|
HTMLBLOCK: "HTMLBLOCK",
|
||||||
HRULE: "HRULE",
|
HRULE: "HRULE",
|
||||||
REFERENCE: "REFERENCE",
|
REFERENCE: "REFERENCE",
|
||||||
NOTE: "NOTE",
|
NOTE: "NOTE",
|
||||||
DEFINITIONLIST: "DEFINITIONLIST",
|
DEFINITIONLIST: "DEFINITIONLIST",
|
||||||
DEFTITLE: "DEFTITLE",
|
DEFTITLE: "DEFTITLE",
|
||||||
DEFDATA: "DEFDATA",
|
DEFDATA: "DEFDATA",
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user