Skip to content

Commit

Permalink
Dont wrap tags within inline parents (markdoc#230)
Browse files Browse the repository at this point in the history
* dont wrap tags within inline parents

* simplify implementation
  • Loading branch information
mfix-stripe authored Sep 29, 2022
1 parent 7ffe795 commit 73933cf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/formatter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,16 @@ Yes!
stable(expected);
});

it('long inline tags', () => {
const source = `{% button type="button" href="https://example.com/a-very-long-inline-tag" %}A very long inline tag{% /button %}
`;
check(source, source);

const inlineParent = `### {% image src="/src" alt="A very long alt text to test if the tag wraps or not" /%}
`;
check(inlineParent, inlineParent);
});

it('long tags with maxTagOpeningWidth=Infinity', () => {
const source = `
{% tag a=true b="My very long text well over 80 characters in total" c=123456789 d=false /%}
Expand Down
2 changes: 1 addition & 1 deletion src/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ function* formatNode(n: Node, o: Options = {}) {
(o.maxTagOpeningWidth || MAX_TAG_OPENING_WIDTH);

// {% tag attributes={...} %}
yield (isLongTagOpening
yield (!n.inline && isLongTagOpening
? tag.join(NL + SPACE.repeat(open.length) + indent)
: inlineTag) +
SPACE +
Expand Down

0 comments on commit 73933cf

Please sign in to comment.