diff --git a/bin/jqt b/bin/jqt index 1809948..593cd7d 100755 --- a/bin/jqt +++ b/bin/jqt @@ -93,7 +93,7 @@ function expand_jqt +siqi "'" "'" '' # literal string; like sh single quotes +siQi '"' '"' '' # interpolated string; like sh double quotes +ssss '' '' # preserved XML comments - +sSSS '{{' '}}' '' # jq processing + +sSSS '{{' '}}' '' # preserved for jq processing +sSSS '{%' '%}' '' +sSSS '{#' '#}' '' ) @@ -115,12 +115,12 @@ function expand_md local -r -a user=( -U '<%' '>' '\B' '\B' '\W>' '<' '>' '$' '' ) local -r -a meta=( -M '<%' '>' '\B' '\B' '\W>' '<' '>' ) local -r -a skips=( - +sccc '&\n' '' '' - +sccc '<#' '#>\n' '' - +siqi "'" "'" '\' - +siQi '"' '"' '\' - +ssss '' '' - +ssss '`' '`' '' + +sccc '&\n' '' '' # continuation line (& and \n removed) + +sccc '<#' '#>\n' '' # multiline comment, must end in \n + +siqi "'" "'" '\' # literal string; like sh single quotes + +siQi '"' '"' '\' # interpolated string; like sh double quotes + +ssss '' '' # preserved XML comments + +ssss '`' '`' '' # MarkDown code regions +ssss '\n```' '\n```' '' +ssss '\n~~~' '\n~~~' '' ) @@ -141,18 +141,18 @@ function expand_json local -r -a user=( -U '&' ';' '(\W' ',\W' ')' '(' ')' '$' '' ) local -r -a meta=( -M '' '\b' '\b' '>' '<' '>' ) local -r -a skips=( - +sccc '&\n' '' '' - +cccc '/*' '*/' - +cccc '//' '\n' - +siqi "'" "'" '\' - +sSSS '"' '"' '\' + +sccc '&\n' '' '' # continuation line (& and \n removed) + +cccc '/*' '*/' # multiline comment + +cccc '//' '\n' # line comment + +sqqq '`' '`' '\' # literal string; like sh single quotes + +sSSS '"' '"' '\' # JSON string ) local -r -a predefined=( - -Damp='&' - -Dapos="'" - -Dgt='>' - -Dlt='<' - -Dquot='"' + -D amp='&' + -D apos="'" + -D gt='>' + -D lt='<' + -D quot='"' ) gpp --nostdinc \ --warninglevel 2 \ @@ -172,11 +172,12 @@ function expand_css local -r -a user=( -U '' '' '(\W' ',\W' ')' '(' ')' '$' '' ) local -r -a meta=( -M '\n&' '\n' '\b' '\b' '\n' '(' ')' ) local -r -a skips=( - +cccc '&\n' '' - +cccc '/*' '*/' - +cccc '//' '\n' - +ssss '"' '"' '\' - +ssss "'" "'" '\' + +cccc '&\n' '' # continuation line (& and \n removed) + +cccc '/*' '*/' # multiline comment + +cccc '//' '\n' # line comment + +sqqq '`' '`' '\' # literal string; like sh single quotes + +ssss '"' '"' '\' # CSS string + +ssss "'" "'" '\' # CSS string ) local -r -a gpp_opts=( --nostdinc diff --git a/docs/config.yaml b/docs/config.yaml index 61f6f93..0faf33d 100644 --- a/docs/config.yaml +++ b/docs/config.yaml @@ -10,15 +10,13 @@ title: jqt · the jq template engine baseURL: https://fadado.github.com/jqt/ lang: en +logo: "❴❴❏❵❵" author: - email: jordinas@gmail.com name: Joan Josep Ordinas Rosa menu: -- URL: ./index.html - id: content/home - name: Home - URL: ./engine.html id: content/engine name: Engine diff --git a/docs/content/data.md b/docs/content/data.md index 937b3d8..a128c4d 100644 --- a/docs/content/data.md +++ b/docs/content/data.md @@ -78,7 +78,7 @@ Inside macro definitions argument references are prefixed by a dollar (`$1`, `$2 -{ "price": "&price(100);" } +{ "price": "&price(100)" } ``` Warning: you must read the [GPP manual][GPPMAN] if you want to know all the gory details. @@ -94,15 +94,15 @@ The main use of the preprocessor is to remove comments in the CPP style: Double quoted strings are also defined as skips, and backticks can be used to disable macro expansion (inside double quoted strings backticks are ignored). -This table summarize all the available skips in JSON files: +This table summarizes all the available skips in JSON files: Delimiters Macro expansion Delimiters removed Content removed ------------- --------------- ------------------ --------------- `&\n`[^1] No Yes There is no content `/*` `*/` No Yes Yes `//` `\n`[^2] No Yes Yes -`"` `"` Yes No No `` ` `` `` ` `` No Yes No +`"` `"` Yes No No Table: **Semantics for all JSON skips** diff --git a/docs/content/document.md b/docs/content/document.md index a1ea63b..efe0361 100644 --- a/docs/content/document.md +++ b/docs/content/document.md @@ -118,27 +118,31 @@ Fenced code blocks with tildes (~~~) or backticks (```) ``` ~~~ -This table summarize all the available document skips: - - Delimiters Place Macro expansion Delimiters removed Content removed -------------- ----- --------------- ------------------ --------------- -`&\n`[^1] Document text No Yes There is no content -`<#` `#>\n` Document text No Yes Yes -`` Document text No No No -`'` `'` User defined macros No Yes No -`"` `"` User defined macros Yes Yes No -`` ` `` `` ` `` Document text No No No -\\n```[^2] Document text No No No -`\n~~~`[^3] Document text No No No +This table summarizes all the available document skips: + + Delimiters Macro expansion Delimiters removed Content removed +------------- --------------- ------------------ --------------- +`&\n`[^1] No Yes There is no content +`<#` `#>\n` No Yes Yes +`'` `'`[^2] No Yes No +`"` `"`[^3] Yes Yes No +`` No No No +`` ` `` `` ` `` No No No +\\n```[^4] No No No +`\n~~~`[^5] No No No Table: **Semantics for all document skips** [^1]: An ampersand followed by a newline is treated as a line continuation (that is, the ampersand and the newline are removed and effectively ignored). -[^2]: Blocks of code fenced between two lines with three or more backticks. +[^2]: Only inside user defined macros. -[^3]: Blocks of code fenced between two lines with three or more tildes. +[^3]: Only inside user defined macros. + +[^4]: Blocks of code fenced between two lines with three or more backticks. + +[^5]: Blocks of code fenced between two lines with three or more tildes. ### Pandoc’s Markdown diff --git a/docs/content/opt/P.md b/docs/content/opt/P.md index ac27f1a..dae161c 100644 --- a/docs/content/opt/P.md +++ b/docs/content/opt/P.md @@ -1,5 +1,5 @@ -P LANGUAGE -: Expand input data with the macro-processor (language must be `jqt`, `md`, +: Expand input data with the macro-processor (LANGUAGE must be `jqt`, `md`, `json`, `css` or `css-min`). <# diff --git a/docs/content/template.md b/docs/content/template.md index e96cd0a..1472035 100644 --- a/docs/content/template.md +++ b/docs/content/template.md @@ -131,24 +131,28 @@ be enabled or disabled. String delimiters can be copied, or not, to the output: All jqt template delimited regions: {#...#}, {%...%}, {{...}} ~~~ -This table summarize all the available template skips: - - Delimiters Place Macro expansion Delimiters removed Content removed -------------- ----- --------------- ------------------ --------------- -`&\n`[^1] Template text No Yes There is no content -`<#` `#>` Template text No Yes Yes -`'` `'` User defined macros No Yes No -`"` `"` User defined macros Yes Yes No -`` Template text No No No -`{{` `}}` Template text No No No -`{%` `%}` Template text No No No -`{#` `#}` Template text No No No +This table summarizes all the available template skips: + + Delimiters Macro expansion Delimiters removed Content removed +------------- --------------- ------------------ --------------- +`&\n`[^1] No Yes There is no content +`<#` `#>` No Yes Yes +`'` `'`[^2] No Yes No +`"` `"`[^3] Yes Yes No +`` No No No +`{{` `}}` No No No +`{%` `%}` No No No +`{#` `#}` No No No Table: **Semantics for all template skips** [^1]: An ampersand followed by a newline is treated as a line continuation (that is, the ampersand and the newline are removed and effectively ignored). +[^2]: Only inside user defined macros. + +[^3]: Only inside user defined macros. + ### Code snippets The input text for a template is UTF-8 text with diff --git a/docs/presentation/jqt.css b/docs/presentation/jqt.css index 391f58f..4b69ce4 100644 --- a/docs/presentation/jqt.css +++ b/docs/presentation/jqt.css @@ -32,11 +32,16 @@ #MENU li.logo a { // "picture" font-weight: normal; - font-size: 160%; + font-size: 150%; text-decoration: none; + color: DarkCyan; background-color: inherit; } +#MENU li.logo a:hover { // "picture" + text-decoration: overline; +} + #MENU li.logo span { // version font-size: 12px; font-weight: bold; @@ -49,12 +54,12 @@ #MENU a:hover { padding: 2px; - background-color: gainsboro; + background-color: Gainsboro; } #MENU a.current { padding: 2px; - background-color: gainsboro; + background-color: Gainsboro; } // diff --git a/docs/structure/default.html b/docs/structure/default.html index 2bd23b9..ae19e06 100644 --- a/docs/structure/default.html +++ b/docs/structure/default.html @@ -12,7 +12,8 @@ diff --git a/tests/expand/mpjson-10.json b/tests/expand/mpjson-10.json index c507027..31d237d 100644 --- a/tests/expand/mpjson-10.json +++ b/tests/expand/mpjson-10.json @@ -1,6 +1,6 @@ // XHTML entities & { - &E('price, with discount, is',88) + &E(`price, with discount, is`,88) } // vim:sw=4:ts=4:ai:et:syntax=javascript