From 9ec652af449a03dad646fc82a381f61e75090ec4 Mon Sep 17 00:00:00 2001
From: Yann Herklotz
Date: Fri, 23 Mar 2018 01:38:30 +0000
Subject: [Clean] Cleaning up a bit
---
FMark/src/Common/MarkdownGen/MarkdownGen.fs | 21 +++++++++------------
FMark/src/FMarkCLI/FMarkCLI.fs | 19 ++++++++++---------
2 files changed, 19 insertions(+), 21 deletions(-)
diff --git a/FMark/src/Common/MarkdownGen/MarkdownGen.fs b/FMark/src/Common/MarkdownGen/MarkdownGen.fs
index 8abf61c..13008ef 100644
--- a/FMark/src/Common/MarkdownGen/MarkdownGen.fs
+++ b/FMark/src/Common/MarkdownGen/MarkdownGen.fs
@@ -74,9 +74,9 @@ let mdTable (rows: PRow list) =
| false ->
mdInlineElements line
|> (fun cellContent -> pStr + cellContent + "|")
-
+
List.fold (cellsFolder alignRow) "|" row
-
+
let foldRows alignRow rows =
let rowsFolder alignRow pStr row =
pStr + (foldCells alignRow) row + "\n"
@@ -90,20 +90,20 @@ let mdTable (rows: PRow list) =
/// recursively process a list
let rec mdList list =
let mdListItem ord tab (pStr,pCount) li =
- let makeTabs num =
+ let makeTabs num =
if num <= 0 then "" else String.replicate num "\t"
- let retFold s = pStr + s, pCount + 1;
+ let retFold s = pStr + s, pCount + 1
match li with
- | StringItem(line) -> mdInlineElements line |> (fun s ->
+ | StringItem(line) -> mdInlineElements line |> (fun s ->
match ord,s with
| _,"" -> ""
- | true,_ ->
+ | true,_ ->
sprintf "%s%i. %s\n" (makeTabs tab) pCount s
|> logPassN logger.Debug
- | false,_ ->
+ | false,_ ->
sprintf "%s- %s\n" (makeTabs tab) s) |> retFold
| NestedList(list) -> mdList list |> retFold
-
+
match list with
| {ListType=lt; ListItem=liS; Depth=d} ->
let ord = match lt with | OL _ -> true | UL -> false
@@ -115,7 +115,7 @@ let mdHeader header =
match header with
| {HeaderName=line;Level=lv} ->
(line |> mdInlineElements)
- |> sprintf "%s %s\n" (String.replicate lv "#")
+ |> sprintf "%s %s\n" (String.replicate lv "#")
/// process HTML body part
let mdBody pObjs =
@@ -131,6 +131,3 @@ let mdBody pObjs =
//| Footnote (fnId, _) -> mdInlineFootnote fnId
| _ -> sprintf "%A is not implemented" pObj
List.fold folder "" pObjs
-
-
-
diff --git a/FMark/src/FMarkCLI/FMarkCLI.fs b/FMark/src/FMarkCLI/FMarkCLI.fs
index 667a720..0364bb9 100644
--- a/FMark/src/FMarkCLI/FMarkCLI.fs
+++ b/FMark/src/FMarkCLI/FMarkCLI.fs
@@ -48,6 +48,7 @@ let setLoggerLevel (r:ParseResults)=
r.GetResult(Loglevel,defaultValue=LogLevel.FATAL)
|> function | l -> globLog <- Logger(l) // update the global logger with the new log value
r
+
let welcomeMsg a =
globLog.Info None "Welcome to FMark!"
a
@@ -69,15 +70,15 @@ let processCLI argv =
|> ifFlagRunTests
|> ifFileReadFrom
|> function
- | None(_) -> () // Do nothing
- | Some(instr,fname) ->
- let format = results.GetResult(Format,defaultValue = HTML) // Find out format and output file name, convert.
- let defaultOutfile = if format=HTML then replaceChars "\.[a-zA-Z]+$" ".html" fname else replaceChars "\.[a-zA-Z]+$" "1.md" fname
- let outFile = results.GetResult(Output,defaultValue=defaultOutfile)
- FMark.processString "" format instr
- |> function
- | Ok(s)
- | Error(s) -> FileIO.writeToFile outFile s
+ | None(_) -> () // Do nothing
+ | Some(instr,fname) ->
+ let format = results.GetResult(Format,defaultValue = HTML) // Find out format and output file name, convert.
+ let defaultOutfile = if format=HTML then replaceChars "\.[a-zA-Z]+$" ".html" fname else replaceChars "\.[a-zA-Z]+$" "1.md" fname
+ let outFile = results.GetResult(Output,defaultValue=defaultOutfile)
+ FMark.processString "" format instr
+ |> function
+ | Ok(s)
+ | Error(s) -> FileIO.writeToFile outFile s
[]
let main argv =
--
cgit
From 1579d9817c8fdfd5594ef231b66461dbaf05728e Mon Sep 17 00:00:00 2001
From: Yann Herklotz
Date: Fri, 23 Mar 2018 02:42:07 +0000
Subject: [Eg] Adding cool macros
---
examples/example.fmark | 5 ++++-
examples/macros.fmark | 10 ++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
create mode 100644 examples/macros.fmark
diff --git a/examples/example.fmark b/examples/example.fmark
index 61dfc7d..a22859e 100644
--- a/examples/example.fmark
+++ b/examples/example.fmark
@@ -1,12 +1,15 @@
-
# FMark Example
+{{ include ./macros.fmark }}
+
## Table of contents
%%TOC
## Macros
+{{ input(This is the text to be inputted into the Textbox) }}
+
{% macro make_table(00;01;02;10;11;12;20;21;22)
|{{00}}|{{01}}|{{02}}|
diff --git a/examples/macros.fmark b/examples/macros.fmark
new file mode 100644
index 0000000..3f542c0
--- /dev/null
+++ b/examples/macros.fmark
@@ -0,0 +1,10 @@
+{% macro input(text)
+
+
+
+%}
\ No newline at end of file
--
cgit
From 566b92541201e685e02ba40dde225cf999578043 Mon Sep 17 00:00:00 2001
From: Yann Herklotz
Date: Fri, 23 Mar 2018 03:06:35 +0000
Subject: [html] Adding html type
---
FMark/src/Common/Types.fs | 3 ++-
examples/macros.fmark | 14 ++++++++++++++
examples/test.css | 3 +++
3 files changed, 19 insertions(+), 1 deletion(-)
create mode 100644 examples/test.css
diff --git a/FMark/src/Common/Types.fs b/FMark/src/Common/Types.fs
index a87aa19..94f4027 100644
--- a/FMark/src/Common/Types.fs
+++ b/FMark/src/Common/Types.fs
@@ -10,6 +10,7 @@ type Language =
type Token =
| CODEBLOCK of string * Language
| LITERAL of string
+ | HTMLLIT of string
| WHITESPACE of size: int
| NUMBER of string
| HASH | PIPE | EQUAL | MINUS | PLUS | ASTERISK | DOT | COMMA
@@ -84,4 +85,4 @@ type Cell with
member c.GetParams = match c with
| Contents(toks,head,align) -> toks,head,align
-type OutFormat = HTML | Markdown
\ No newline at end of file
+type OutFormat = HTML | Markdown
diff --git a/examples/macros.fmark b/examples/macros.fmark
index 3f542c0..1fa4351 100644
--- a/examples/macros.fmark
+++ b/examples/macros.fmark
@@ -1,3 +1,17 @@
+
+
{% macro input(text)
",
- [LITERAL ""; LITERAL "
"; LITERAL "
"; LITERAL "
"; LITERAL "
"; LITERAL "
"
- LITERAL "
"; LITERAL " "; LITERAL "
"; LITERAL ""; LITERAL ""; LITERAL ""
- LITERAL ""; LITERAL ""; LITERAL ""; ENDLINE]
+ [HTMLLIT ""; HTMLLIT "
"; HTMLLIT "
"; HTMLLIT "
"; HTMLLIT "
"; HTMLLIT "
"
+ HTMLLIT "
"; HTMLLIT " "; HTMLLIT "
"; HTMLLIT ""; HTMLLIT ""; HTMLLIT ""
+ HTMLLIT ""; HTMLLIT ""; HTMLLIT ""; ENDLINE]
"Half opened tag should just be outputted",
"<",
- [LITERAL ""; LITERAL "<"; ENDLINE]
+ [HTMLLIT ""; HTMLLIT "<"; ENDLINE]
"Half opened with text after should be as expected",
""; LITERAL ""; HTMLLIT ">s",
- [LITERAL ""; LITERAL ">s"; ENDLINE]
+ [HTMLLIT "
"; HTMLLIT ">s"; ENDLINE]
]
/// Tests for the complete lexers with a string list as input
@@ -384,9 +384,9 @@ let lexListTest =
"This should not, This should not be tokenized []"],
[LITERAL "This"; WHITESPACE 1; LITERAL "should"; WHITESPACE 1; LITERAL "not"
WHITESPACE 1; LITERAL "be"; WHITESPACE 1; LITERAL "passed"; WHITESPACE 1
- LITERAL "through"; ENDLINE; LITERAL "
"; LITERAL "This should just all be passed through, "; LITERAL "
"
+ LITERAL "through"; ENDLINE; HTMLLIT ""; HTMLLIT "This should just all be passed through, "; HTMLLIT "
"
ENDLINE; LITERAL "This"; WHITESPACE 1; LITERAL "should"; WHITESPACE 1; LITERAL "not"; COMMA; WHITESPACE 1
- LITERAL ""; LITERAL "This should not be tokenized []"; LITERAL ""; ENDLINE]
+ HTMLLIT ""; HTMLLIT "This should not be tokenized []"; HTMLLIT ""; ENDLINE]
]
// --------------------------------------------------
--
cgit
From 1edac097c4809ce1efd92559f6880af115694c9c Mon Sep 17 00:00:00 2001
From: Yann Herklotz
Date: Fri, 23 Mar 2018 03:30:43 +0000
Subject: Adding html type
---
FMark/src/Common/Types.fs | 2 ++
1 file changed, 2 insertions(+)
diff --git a/FMark/src/Common/Types.fs b/FMark/src/Common/Types.fs
index 94f4027..46667c9 100644
--- a/FMark/src/Common/Types.fs
+++ b/FMark/src/Common/Types.fs
@@ -25,7 +25,9 @@ type TFrmtedString =
| Line of InlineElement list
| Strike of InlineElement list
| Literal of string
+ | Html of string
| Code of string
+
and InlineElement =
| FrmtedString of TFrmtedString
| Link of HyperText: TFrmtedString * URL: string
--
cgit
From dbc9281e3e97b557d2a4d17c345cc1c38c935a5b Mon Sep 17 00:00:00 2001
From: Yann Herklotz
Date: Fri, 23 Mar 2018 03:42:06 +0000
Subject: [html] Removing newlines from html blocks
---
FMark/src/Common/Lexer/Lexer.fs | 25 +++++++++++++------------
FMark/src/Common/Lexer/LexerTest.fs | 28 ++++++++++++++--------------
FMark/src/Common/Types.fs | 2 --
3 files changed, 27 insertions(+), 28 deletions(-)
diff --git a/FMark/src/Common/Lexer/Lexer.fs b/FMark/src/Common/Lexer/Lexer.fs
index 5e2c7d6..a7bd111 100644
--- a/FMark/src/Common/Lexer/Lexer.fs
+++ b/FMark/src/Common/Lexer/Lexer.fs
@@ -48,23 +48,23 @@ let nextToken state s =
match s, state with
| EscapedCharTok n, _ -> n, state
| HTMLSingleton (s, r), Normal ->
- (HTMLLIT s, r), Normal
+ (LITERAL s, r), Normal
| HTMLStartTag (s, [t], r), Normal ->
- (HTMLLIT s, r), InHTMLTag (t, 1)
+ (LITERAL s, r), InHTMLTag (t, 1)
| HTMLStartTag (s, [t], r), InHTMLTag (tag, d) ->
if t = tag then
- (HTMLLIT s, r), InHTMLTag (tag, d+1)
+ (LITERAL s, r), InHTMLTag (tag, d+1)
else
- (HTMLLIT s, r), InHTMLTag (tag, d)
+ (LITERAL s, r), InHTMLTag (tag, d)
| HTMLEndTag (s, [t], r), InHTMLTag (tag, d) ->
if t = tag then
- if d = 1 then (HTMLLIT s, r), Normal
- else (HTMLLIT s, r), InHTMLTag (tag, d-1)
- else (HTMLLIT s, r), InHTMLTag (tag, d)
+ if d = 1 then (LITERAL s, r), Normal
+ else (LITERAL s, r), InHTMLTag (tag, d-1)
+ else (LITERAL s, r), InHTMLTag (tag, d)
| RegexMatch "^.+?(?=<)" (s, _, r), InHTMLTag (t, d) ->
- (HTMLLIT s, r), InHTMLTag (t, d)
+ (LITERAL s, r), InHTMLTag (t, d)
| RegexMatch "^.*" (s, _, r), InHTMLTag (t, d) ->
- (HTMLLIT s, r), InHTMLTag (t, d)
+ (LITERAL s, r), InHTMLTag (t, d)
| CharacterTok n, _ -> n, state
| RegexMatch @"^\s+" (m, _, s), _ ->
(replaceChars "\t" " " m
@@ -80,8 +80,9 @@ let nextToken state s =
/// Lexes a whole string and returns the result as a Token list
let lexS state source =
let rec lexS' state s tokList =
- match s with
- | ""-> ENDLINE :: tokList
+ match s, state with
+ | "", InHTMLTag _ -> tokList
+ | "", _ -> ENDLINE :: tokList
| _ ->
let (nt, st'), nstate = nextToken state s
nt :: tokList |> lexS' nstate st'
@@ -102,7 +103,7 @@ let returnTokens = function
| _, InCodeBlock (s, l) ->
[CODEBLOCK (s, l); ENDLINE]
| tok, InHTMLTag (str, _) ->
- tok @ [HTMLLIT str; ENDLINE]
+ tok @ [LITERAL str; ENDLINE]
| tok, _ ->
tok
diff --git a/FMark/src/Common/Lexer/LexerTest.fs b/FMark/src/Common/Lexer/LexerTest.fs
index 9e65a89..6ed1132 100644
--- a/FMark/src/Common/Lexer/LexerTest.fs
+++ b/FMark/src/Common/Lexer/LexerTest.fs
@@ -309,46 +309,46 @@ let lexTest =
"One line html",
"This is a span element",
- [HTMLLIT ""; HTMLLIT "This is a span element"; HTMLLIT ""; ENDLINE]
+ [LITERAL ""; LITERAL "This is a span element"; LITERAL ""; ENDLINE]
"Online closing html",
"",
- [HTMLLIT ""; ENDLINE]
+ [LITERAL ""; ENDLINE]
"HTML with non-HTML start",
"This is an image: Hello World",
[LITERAL "This"; WHITESPACE 1; LITERAL "is"; WHITESPACE 1; LITERAL "an"
- WHITESPACE 1; LITERAL "image"; COLON; WHITESPACE 1; HTMLLIT ""
- HTMLLIT "Hello World"; HTMLLIT ""; ENDLINE]
+ WHITESPACE 1; LITERAL "image"; COLON; WHITESPACE 1; LITERAL ""
+ LITERAL "Hello World"; LITERAL ""; ENDLINE]
"Singleton HTML passthrough",
"Singleton
passthrough and more text",
- [LITERAL "Singleton"; WHITESPACE 1; HTMLLIT "
"; WHITESPACE 1; LITERAL "passthrough"
+ [LITERAL "Singleton"; WHITESPACE 1; LITERAL "
"; WHITESPACE 1; LITERAL "passthrough"
WHITESPACE 1; LITERAL "and"; WHITESPACE 1; LITERAL "more"; WHITESPACE 1
LITERAL "text"; ENDLINE]
"HTML image tag",
"Embedding an in text",
- [LITERAL "Embedding"; WHITESPACE 1; LITERAL "an"; WHITESPACE 1; HTMLLIT ""
+ [LITERAL "Embedding"; WHITESPACE 1; LITERAL "an"; WHITESPACE 1; LITERAL ""
WHITESPACE 1; LITERAL "in"; WHITESPACE 1; LITERAL "text"; ENDLINE]
"A lot of nested tags",
"
",
- [HTMLLIT ""; HTMLLIT "
"; HTMLLIT "
"; HTMLLIT "
"; HTMLLIT "
"; HTMLLIT "
"
- HTMLLIT "
"; HTMLLIT " "; HTMLLIT "
"; HTMLLIT ""; HTMLLIT ""; HTMLLIT ""
- HTMLLIT ""; HTMLLIT ""; HTMLLIT ""; ENDLINE]
+ [LITERAL ""; LITERAL "
"; LITERAL "
"; LITERAL "
"; LITERAL "
"; LITERAL "
"
+ LITERAL "
"; LITERAL " "; LITERAL "
"; LITERAL ""; LITERAL ""; LITERAL ""
+ LITERAL ""; LITERAL ""; LITERAL ""; ENDLINE]
"Half opened tag should just be outputted",
"<",
- [HTMLLIT ""; HTMLLIT "<"; ENDLINE]
+ [LITERAL ""; LITERAL "<"; ENDLINE]
"Half opened with text after should be as expected",
""; HTMLLIT ""; LITERAL ">s",
- [HTMLLIT ""; HTMLLIT ">s"; ENDLINE]
+ [LITERAL "
"; LITERAL ">s"; ENDLINE]
]
/// Tests for the complete lexers with a string list as input
@@ -384,9 +384,9 @@ let lexListTest =
"This should not, This should not be tokenized []"],
[LITERAL "This"; WHITESPACE 1; LITERAL "should"; WHITESPACE 1; LITERAL "not"
WHITESPACE 1; LITERAL "be"; WHITESPACE 1; LITERAL "passed"; WHITESPACE 1
- LITERAL "through"; ENDLINE; HTMLLIT "
"; HTMLLIT "This should just all be passed through, "; HTMLLIT "
"
+ LITERAL "through"; ENDLINE; LITERAL ""; LITERAL "This should just all be passed through, "; LITERAL "
"
ENDLINE; LITERAL "This"; WHITESPACE 1; LITERAL "should"; WHITESPACE 1; LITERAL "not"; COMMA; WHITESPACE 1
- HTMLLIT ""; HTMLLIT "This should not be tokenized []"; HTMLLIT ""; ENDLINE]
+ LITERAL ""; LITERAL "This should not be tokenized []"; LITERAL ""; ENDLINE]
]
// --------------------------------------------------
diff --git a/FMark/src/Common/Types.fs b/FMark/src/Common/Types.fs
index 46667c9..65ed79b 100644
--- a/FMark/src/Common/Types.fs
+++ b/FMark/src/Common/Types.fs
@@ -10,7 +10,6 @@ type Language =
type Token =
| CODEBLOCK of string * Language
| LITERAL of string
- | HTMLLIT of string
| WHITESPACE of size: int
| NUMBER of string
| HASH | PIPE | EQUAL | MINUS | PLUS | ASTERISK | DOT | COMMA
@@ -25,7 +24,6 @@ type TFrmtedString =
| Line of InlineElement list
| Strike of InlineElement list
| Literal of string
- | Html of string
| Code of string
and InlineElement =
--
cgit
From ee3202f55a1da87b2f10c9bc4e5bbcd95176e19d Mon Sep 17 00:00:00 2001
From: Yann Herklotz
Date: Fri, 23 Mar 2018 03:43:35 +0000
Subject: [html] Removed ENDLINE from test
---
FMark/src/Common/Lexer/LexerTest.fs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/FMark/src/Common/Lexer/LexerTest.fs b/FMark/src/Common/Lexer/LexerTest.fs
index 6ed1132..7de338d 100644
--- a/FMark/src/Common/Lexer/LexerTest.fs
+++ b/FMark/src/Common/Lexer/LexerTest.fs
@@ -340,15 +340,15 @@ let lexTest =
"Half opened tag should just be outputted",
"<",
- [LITERAL ""; LITERAL "<"; ENDLINE]
+ [LITERAL ""; LITERAL "<"]
"Half opened with text after should be as expected",
""; LITERAL ""; LITERAL ">s",
- [LITERAL ""; LITERAL ">s"; ENDLINE]
+ [LITERAL "
"; LITERAL ">s"]
]
/// Tests for the complete lexers with a string list as input
--
cgit
From e415a39dc0e77743db382a90bfde73d6e6b400dd Mon Sep 17 00:00:00 2001
From: Yann Herklotz
Date: Fri, 23 Mar 2018 03:54:49 +0000
Subject: [examples] Adding more examples
---
examples/macros.fmark | 7 +++++--
examples/test.css | 2 +-
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/examples/macros.fmark b/examples/macros.fmark
index 1fa4351..fe69b1b 100644
--- a/examples/macros.fmark
+++ b/examples/macros.fmark
@@ -1,4 +1,4 @@
-
+sdassdd
+
+
{% macro input(text)