Skip to content

Commit

Permalink
Add parent nodes to \include children on multipage mode
Browse files Browse the repository at this point in the history
Also use AstArgument for those autogenerated nodes.

Fix #21
  • Loading branch information
cirosantilli committed Apr 18, 2020
1 parent 0fae1b1 commit de3f8b5
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1732,20 +1732,20 @@ function parse(tokens, macros, options, extra_returns={}) {
AstType.MACRO,
Macro.HEADER_MACRO_NAME,
{
'level': [
'level': new AstArgument([
new PlaintextAstNode(
ast.line,
ast.column,
(cur_header_level + 1).toString(),
)
],
[Macro.TITLE_ARGUMENT_NAME]: [
], ast.line, ast.column),
[Macro.TITLE_ARGUMENT_NAME]: new AstArgument([
new PlaintextAstNode(
ast.line,
ast.column,
header_node_title
)
]
], ast.line, ast.column),
},
ast.line,
ast.column,
Expand All @@ -1766,31 +1766,31 @@ function parse(tokens, macros, options, extra_returns={}) {
AstType.MACRO,
Macro.PARAGRAPH_MACRO_NAME,
{
'content': [
'content': new AstArgument([
new AstNode(
AstType.MACRO,
'x',
{
'href': [
'href': new AstArgument([
new PlaintextAstNode(
ast.line,
ast.column,
href
)
],
'content': [
], ast.line, ast.column),
'content': new AstArgument([
new PlaintextAstNode(
ast.line,
ast.column,
'This section is present in another page, follow this link to view it.'
)
],
], ast.line, ast.column),
},
ast.line,
ast.column,
{from_include: true},
),
],
], ast.line, ast.column),
},
ast.line,
ast.column,
Expand All @@ -1802,6 +1802,9 @@ function parse(tokens, macros, options, extra_returns={}) {
// - all child includes will be resolved on the sub-render call
// - the current header level must not move, so that consecutive \include
// calls won't nest into one another
for (const new_child_node of new_child_nodes) {
new_child_node.parent_node = ast.parent_node;
}
parent_arg.push(...new_child_nodes);
}
} else if (macro_name === Macro.CIRODOWN_EXAMPLE_MACRO_NAME) {
Expand All @@ -1817,21 +1820,22 @@ function parse(tokens, macros, options, extra_returns={}) {
AstType.MACRO,
Macro.PARAGRAPH_MACRO_NAME,
{
'content': [
'content': new AstArgument([
new PlaintextAstNode(
ast.line,
ast.column,
'which renders as:',
)
],
], ast.line, ast.column),
},
ast.line,
ast.column,
),
new AstNode(
AstType.MACRO,
'q',
{'content': convert_include(
{
'content': convert_include(
convert_arg_noescape(ast.args.content, id_context),
options,
0,
Expand Down

0 comments on commit de3f8b5

Please sign in to comment.