Skip to content

Commit

Permalink
Added all MP modes
Browse files Browse the repository at this point in the history
  • Loading branch information
fadado committed Aug 26, 2016
1 parent 1cf137a commit 1d91f29
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 60 deletions.
45 changes: 23 additions & 22 deletions bin/jqt
Original file line number Diff line number Diff line change
Expand Up @@ -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 '{#' '#}' ''
)
Expand All @@ -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~~~' ''
)
Expand All @@ -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 \
Expand All @@ -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
Expand Down
4 changes: 1 addition & 3 deletions docs/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@
title: jqt · the jq template engine
baseURL: https://fadado.github.com/jqt/
lang: en
logo: "❴❴❏❵❵"

author:
- email: [email protected]
name: Joan Josep Ordinas Rosa

menu:
- URL: ./index.html
id: content/home
name: Home
- URL: ./engine.html
id: content/engine
name: Engine
Expand Down
6 changes: 3 additions & 3 deletions docs/content/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Inside macro definitions argument references are prefixed by a dollar (`$1`, `$2
<!define euro \u20AC>
<!define price $1 &euro;>
{ "price": "&price(100);" }
{ "price": "&price(100)" }
```
Warning: you must read the [GPP manual][GPPMAN] if you want to know all the gory details.
Expand All @@ -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**
Expand Down
32 changes: 18 additions & 14 deletions docs/content/document.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<code>\\n&#96;&#96;&#96;</code>[^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
<code>\\n&#96;&#96;&#96;</code>[^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
Expand Down
2 changes: 1 addition & 1 deletion docs/content/opt/P.md
Original file line number Diff line number Diff line change
@@ -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`).

<#
Expand Down
28 changes: 16 additions & 12 deletions docs/content/template.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions docs/presentation/jqt.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

//
Expand Down
3 changes: 2 additions & 1 deletion docs/structure/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

<body>
<ul id="MENU">
{# logo #}<li class="logo"><a href="{{.site.baseURL}}">❴❴❏❵❵</a><span>v<%include "../VERSION"></span></li>
<!--{# logo #}<li class="logo"><a href="{{.site.baseURL}}">❴❴❏❵❵</a><span>v<%include "../VERSION"></span></li>-->
{# logo #}<li class="logo"><a href="index.html">{{.front.logo}}</a><span>v<%include "../VERSION"></span></li>
{% .site.menu[] %}<li><a {{if .id==$M.front._id then "class='current'" else "" end}} href="{{.URL}}">{{.name}}</a></li>
</ul>

Expand Down
2 changes: 1 addition & 1 deletion tests/expand/mpjson-10.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// XHTML entities
<!define E "$1": "$2">&
{
&E('price, with discount, is',88)
&E(`price, with discount, is`,88)
}
// vim:sw=4:ts=4:ai:et:syntax=javascript

0 comments on commit 1d91f29

Please sign in to comment.