fleck --version
# fleck: [ver='bare:0.0.4-alpha+conf.1'][buildAt='2023-05-19T08:22:37.689817'][buildBy='[email protected]']
Features
Better arguments debugging
Previously, arguments were printed via string concatenation when calling cli.Arguments.String()
(is called when fleck is invoked with --debug
), this was changed to stringifying the arguments struct via json.Marshal
:
fleck --debug tester.md
# 2023/05/19 08:02:05 debug: [arguments:
# {
# Files: [
# 'tester.md', ],
# Flags: [
# ], Args: [
# --port: '12345',
# ]
# }]
# 2023/05/19 08:02:05 error: failed to stat the file
Now:
fleck --debug tester.md
# {
# "Flags": {
# "config": false,
# "debug": true,
# "escape-html": false,
# "help": false,
# "keep-temp": false,
# "live-preview": false,
# "math": false,
# "no-prefix": false,
# "no-template": false,
# "preprocessor-enabled": false,
# "shell-macro-enabled": false,
# "silent": false,
# "syntax": false,
# "toc": false,
# "toc-full": false,
# "version": false,
# "watch": false
# },
# "Args": {
# "port": "12345"
# },
# "Files": [
# "tester.md"
# ]
# }
# 2023/05/19 08:03:19 error: stat tester.md: no such file or directory
Markdown
Highlighted text
Fleck now supports highlighted text found in the markdown source in the compiled html via the <mark></mark>
tag:
Source:
this paragraph includes ==highlighted== text
Compiles to:
<p>this paragraph includes <mark>highlighted</mark> text
Strike trough text
Fleck now supports strike-through text found in the markdown source in the compiled html via the <s></s>
tag:
Source:
this paragraph includes ~~strike-trough~~ text
Compiles to:
<p>this paragraph includes <s>strike-trough</s> text
Escape html
Instructs fleck to escape html elements encountered while lexing the markdown source.
fleck test.md
# 2023/05/04 19:41:44 info: compiled 'test.md', took: 459.166µs
fleck --escape-html test.md
# 2023/05/04 19:41:44 info: compiled 'test.md', took: 459.166µs
Consider the following snippet:
# This is the first heading
<h2 class="heading" id="this-is-the-second-heading">
This is the second heading
</h2>
By default fleck will render it as follows:
But supplied with the --escape-html
, fleck escapes the given html:
Config
this feature is notated in the version with
conf.1
Fleck now accepts a new flag for better user experience. The --config
flag and the fleck.json
file were introduced due to the amount of options fleck accepts. To keep the cli experience neat fleck accepts options in the form of a json file if invoked with --config
:
fleck --config
# 2023/05/19 07:48:52 info: got 'config' flag, reading options from 'fleck.json'
# 2023/05/19 07:48:52 info: {
# "Flags": {
# "live-preview": true,
# "math": true,
# "syntax": true
# },
# "Args": null,
# "Files": [
# "test.md"
# ]
# }
# 2023/05/19 07:48:52 info: starting live preview
# 2023/05/19 07:48:52 info: listening on http://localhost:12345/test.html
# 2023/05/19 07:48:52 info: compiled 'test.md', took: 2.20946ms
# 2023/05/19 07:48:52 info: watching for changes...
Documentation:
Loads options and source files from the configuration file fleck.json
. And acts as if the user specified these via the cli.
Example json:
{
"sources": ["test.md"],
"flags": ["syntax", "math", "live-preview"]
}
The above is equivalent to:
fleck -syntax -math -live-preview test.md
The flags
array accepts all flags documented in Usage.md.
Changes
Empty source file
Previously, fleck issues a warning and exists when an empty source file was found, this was changed to simply ignoring the source file if it is empty:
fleck tester.md
# 2023/05/19 07:29:55 warn: file is empty, exiting.
Now:
fleck tester.md
# 2023/05/19 07:31:18 info: detected empty source file (tester.md), skipping
Fixes
Directory as source file
This release fixes a crash caused by invoking fleck with a directory:
fleck .
# panic: runtime error: index out of range [0] with length 0
#
# goroutine 6 [running]:
# github.com/xnacly/fleck/scanner.New({0x7ffd9b38733c?, 0x0?})
# /home/teo/programming/fleck/scanner/scanner.go:37 +0x1bb
# github.com/xnacly/fleck/core.Run({0x7ffd9b38733c, 0x1})
# /home/teo/programming/fleck/core/core.go:162 +0x387
# main.main.func1({0x7ffd9b38733c, 0x1})
# /home/teo/programming/fleck/fleck.go:82 +0x3e5
# created by main.main
# /home/teo/programming/fleck/fleck.go:56 +0x458
fleck .
# 2023/05/19 07:29:12 error: '.' is a directory
# exit status 1
parser assumes next token as language spec
A code block without an explicit language specification produced a bug
which resulted in the parser stripping the next character in the code
block, instead of assigning an empty string to the language. This was
fixed by checking if the language specification exists.
Previously:
```js
console.log("test")
\```
<pre>
<code class="language-">
("test")
</code>
</pre>
Now:
```js
console.log("test")
\```
<pre>
<code class="language-">
console.log("test")
</code>
</pre>
Changelog
# git request-pull 0.0.3-alpha+math.1 https://github.com/xnacly/fleck
xnacly (24):
feat(lexer): add tilde parsing for striketrough text
feat(parser): StrikeTrough tag for code gen
feat(parser): implemented striketrough text
feat(lexer): add support for '='
feat(parser): add support for highlighted text
refactor(parser): removed unused parser.Parser methods
build: update feature to highlight.1
doc(README): updated features
fix(cli): debug options logging
doc: documented new '-escape-html' flag
feat: add '-escape-html' option flag
refactor(parser): replaced strikesthrough and highlight function
chore: update testing
fix(parser): html in code blocks
fix(parser): parser assumes next token as language spec
fix(parser): emphasis parsing
chore: update feature to 'conf'
feat(cli): GetConfigFromFile
feat(cli): FleckConfig struct
refactor(cli): replace stringify with json.Marshal
feat: '-config' option
refactor: remove duplicate ARGUMENTS logging
chore: add fleck.json
fix: index error if source file is a directory
README.md | 2 ++
build.conf | 2 +-
cli/cli.go | 27 +++++++++++++++++++++++++--
cli/constants.go | 35 +++++++++++++++++++++--------------
doc/Features.md | 5 +++++
doc/Usage.md | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------
doc/assets/escaped-html.png | Bin 0 -> 8954 bytes
doc/assets/not-escaped-html.png | Bin 0 -> 8542 bytes
fleck.go | 29 +++++++++++++++++++++--------
fleck.json | 4 ++++
parser/parser.go | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------
parser/tags.go | 19 ++++++++++++++++++-
scanner/scanner.go | 12 ++++++++++--
scanner/scanner_test.go | 19 +++++++++++++++++--
scanner/tests/markdown.md | 4 +++-
scanner/tokens.go | 6 ++++++
test.md | 29 ++++++++++++++++++++---------
17 files changed, 298 insertions(+), 94 deletions(-)
create mode 100644 doc/assets/escaped-html.png
create mode 100644 doc/assets/not-escaped-html.png
create mode 100644 fleck.json