diff options
author | Qieerb <qieerbushe7@gmail.com> | 2018-03-21 20:28:02 +0000 |
---|---|---|
committer | Qieerb <qieerbushe7@gmail.com> | 2018-03-21 20:28:02 +0000 |
commit | 37230937d80b909a3af5a7e4cbb5899f69c8196a (patch) | |
tree | 45d638f7bf0faaff16abed1708a35cdc1285e20b /FMark | |
parent | 86eb9950cd2305af05c3fed2d741691d807d8449 (diff) | |
download | FMark-37230937d80b909a3af5a7e4cbb5899f69c8196a.tar.gz FMark-37230937d80b909a3af5a7e4cbb5899f69c8196a.zip |
fix #131
Diffstat (limited to 'FMark')
-rw-r--r-- | FMark/src/Common/TOCite/TOCite.fs | 28 | ||||
-rw-r--r-- | FMark/src/Common/TOCite/TOCiteTest.fs | 10 |
2 files changed, 32 insertions, 6 deletions
diff --git a/FMark/src/Common/TOCite/TOCite.fs b/FMark/src/Common/TOCite/TOCite.fs index 1b70b23..6e00ff5 100644 --- a/FMark/src/Common/TOCite/TOCite.fs +++ b/FMark/src/Common/TOCite/TOCite.fs @@ -4,6 +4,22 @@ open RefParse open ParserHelperFuncs // -------------------------------------------------------------------------------- +let parseFooterInHeader tokLst = + //only simple footer in header + let rec parseFooterInHeader' toParse tLst = + match tLst with + | FOOTNOTE i::tl -> + let s = string i + parseInLineElements toParse :: [Reference (Literal s, "footnote-"+s)] + :: parseFooterInHeader' [] tl + | CITATION _::tl -> parseFooterInHeader' toParse tl + | a::tl -> parseFooterInHeader' (a::toParse) tl + | [] -> [parseInLineElements toParse] + tokLst + |> List.rev + |> parseFooterInHeader' [] + |> List.rev + |> List.reduce List.append let rec tocParse tocLst depth index : THeader list * Token list = // Detect hashes with whitespace after it @@ -25,10 +41,10 @@ let rec tocParse tocLst depth index : THeader list * Token list = | Some i -> let (h,t) = List.splitAt i tl tocParse t 0 (index+1) - |> fun (x,y) -> {HeaderName = parseInLineElements h; Level = depth}::x, ENDLINE::ENDLINE::(HEADER index)::y + |> fun (x,y) -> {HeaderName = parseFooterInHeader h; Level = depth}::x, ENDLINE::ENDLINE::(HEADER index)::y | None -> - [{HeaderName = parseInLineElements tl; Level = depth}], [ENDLINE;ENDLINE;HEADER index] - //hash without whitespace, need to rebuild hash + [{HeaderName = parseFooterInHeader tl; Level = depth}], [ENDLINE;ENDLINE;HEADER index] + // hash without whitespace, need to rebuild hash | a::tl when depth > 0 -> tocParse tl 0 index |> fun (x,y) -> x, List.append (fakehash depth |> List.rev) (a::y) @@ -110,6 +126,6 @@ let citeGen' tLst = ftLst,tLst let preParser tLst = - tocGen' tLst 0 - |> fun (x,y) -> x, citeGen' y - |> fun (x,(y,z)) -> x, y, z + citeGen' tLst + |> fun (x,y) -> x, tocGen' y 0 + |> fun (x,(y,z)) -> y, x, z
\ No newline at end of file diff --git a/FMark/src/Common/TOCite/TOCiteTest.fs b/FMark/src/Common/TOCite/TOCiteTest.fs index 4fb2d3a..5ec0210 100644 --- a/FMark/src/Common/TOCite/TOCiteTest.fs +++ b/FMark/src/Common/TOCite/TOCiteTest.fs @@ -83,6 +83,16 @@ let testDataHd = [ [ENDLINE;ENDLINE;HEADER 0] ); + "Footer in header", + [ENDLINE;ENDLINE; HASH; WHITESPACE 1; LITERAL "text1"; FOOTNOTE 3; LITERAL "text2"], + ( + [{HeaderName = [FrmtedString (Literal "text1"); + Reference (Literal "3","footnote-3"); + FrmtedString (Literal "text2"); + ]; Level = 1;}], + [ENDLINE;ENDLINE;HEADER 0] + ) + ] let makeHdTest (name,inn,out) = |