-
-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tables Seem To Not Tokenize Properly #563
Comments
Hi @NathanielSunday, The problem is that the line that follow the table need to be blank to break the table... this is the same thing here on GitHub. Your code on GitHubObjects come to life at your command. Choose up to ten nonmagical objects within range that are not being worn or carried. Medium targets count as two objects, Large targets count as four objects, Huge targets count as eight objects. You can't animate any object larger than Huge. Each target animates and becomes a creature under your control until the spell ends or until reduced to 0 hit points. Animated Object Statistics
The same code but with a blank line between the table and the next text lineObjects come to life at your command. Choose up to ten nonmagical objects within range that are not being worn or carried. Medium targets count as two objects, Large targets count as four objects, Huge targets count as eight objects. You can't animate any object larger than Huge. Each target animates and becomes a creature under your control until the spell ends or until reduced to 0 hit points. Animated Object Statistics
An animated object is a construct with AC, hit points, attacks, Strength, and Dexterity determined by its size. Its Constitution is 10 and its Intelligence and Wisdom are 3, and its Charisma is 1. Its speed is 30 feet; if the object lacks legs or other appendages it can use for locomotion, it instead has a flying speed of 30 feet and can hover. If the object is securely attached to a surface or a larger object, such as a chain bolted to a wall, its speed is 0. It has blindsight with a radius of 30 feet and is blind beyond that distance. When the animated object drops to 0 hit points, it reverts to its original object form, and any remaining damage carries over to its original object form. |
Because I am a great guy and I love challenges, if you don't want or are not able to modify the source you can fix the problem by adding a blank line programmatically after a table. In your component (or move this to a service, a pipe or whatever depending on your needs)... get spellDesc(): string {
return this.fixTableEnd(this.spell.desc).join('\n');
}
private fixTableEnd(markdown: string[]): string[] {
const tableStartIndex = markdown.findIndex((line) => line.startsWith('|'));
// if there is no table, return the markdown as is
if (tableStartIndex === -1) {
return markdown;
}
const tableEndIndex = markdown.findIndex((line, index) => index > tableStartIndex && !line.startsWith('|'));
// if the table is the last element or the next element is already an empty string, return the markdown as is
if (tableEndIndex === -1 || markdown[tableEndIndex] === '') {
return markdown;
}
// add an empty line after the table to fix the table end
return [...markdown.slice(0, tableEndIndex), '', ...markdown.slice(tableEndIndex)];
} Then in your HTML template... <div markdown>
{{ spellDesc }}
</div> |
Closing as this behaviour is intended |
I am using v19.0.0 of ngx-markdown. I am having trouble with getting tables to parse properly. It would seem that anything that should be tokenized as a
tag after a table gets tokenized as a part of the table instead. In the TS snippet below, 'spell' is just a template to hold the JSON object and follows the same structure as the JSON object in the API, which I provided through the API link below. I also provided CSS, settings, and an image of errant behavior.
API table example
TS snippet of where the table is being rendered
CSS snippet
Settings snippet
End result

The text was updated successfully, but these errors were encountered: