Open KillyMXI opened 1 month ago
Thank you for spending time to document this. It is extremely useful.
I think parsing of markdown for table cells is probably going to be best handled by a 3rd party. I'll report back with a favoured approach shortly.
Half-assed solution could be to defensively remove line-breaks from any cell contents. But a proper parser would certainly be better than homegrown regexes.
The case of missing description in the index table is most puzzling though - it doesn't seem to fall into the same pattern as others. And I'm not sure what makes that one description special from others.
@KillyMXI I think rather than trying to parse the markdown to html in the table cell it might be a better to provide an option to wrap the markdown in an html table as follows:
export type Token = {
// ...
/**
* The length of the matched substring.
*
* _(Might be different from the text length in case replace value
* was used in a {@link RegexRule}.)_
*/
len: number;
// ...
}
Will create a markdown table and remove all linebreaks from the comments. This will work for short descriptions or if html is being used for block elements.
## Type declaration
| Member | Type | Description |
| :------ | :------ | :------ |
| `len` | `number` | The length of the matched substring. _(Might be different from the text length in case replace value was used in a [RegexRule](../interfaces/RegexRule.md).)_ |
Rather than trying to parse the markdown to html we simply wrap the markdown in an html table. This also means that users will be able to render triple line code blocks in the same way as outside of table cells.
## Type declaration
<table><tr><th>Member</th><th>Type</th><th>Description</th></tr><tr><td>
`len`
</td><td>
`number`
</td><td>
The length of the matched substring.
_(Might be different from the text length in case replace value
was used in a [RegexRule](../interfaces/RegexRule.md).)_
</td></tr></table>
I would be interested to know your thoughts?
I love this idea! It will help keeping everything readable as well.
One note though: with format="table"
, beware of repeating #331 - I see an extra space in the example above.
As discussed, htmlTable
key now available to options in typedoc-plugin-markdown@4.1.0.
Thank you. Trying it now.
First thing I tripped on:
indexFormat
only supports list
and table
.
And table
produces broken result.
So I'm limited to either list
and zero information or table
and cut the documentation from my code to conform the the limitations of table
.
What I wish is that it would be possible to have another option for index - get the first paragraph, trim all line breaks in it. So I can have the right balance of the level of details.
Where htmlTable
is supported - it seems to work wonderfully.
First thing I tripped on:
indexFormat
only supportslist
andtable
. Andtable
produces broken result.
Will update so also supported for index.
What I wish is that it would be possible to have another option for index - get the first paragraph, trim all line breaks in it. So I can have the right balance of the level of details.
Happy to look at this. Can you provide a specific example so I don't implement the wrong thing?
These two were mentioned in the issue above:
/**
* Lexing rule.
*
* Base rule looks for exact match by it's name.
*
* If the name and the lookup string have to be different
* then specify `str` property as defined in {@link StringRule}.
*/
export interface Rule {
// ...
}
Desirable index description: Lexing rule.
/**
* String rule - looks for exact string match that
* can be different from the name of the rule.
*/
export interface StringRule extends Rule {
// ...
}
Desirable index description: String rule - looks for exact string match that can be different from the name of the rule.
This is another one:
/**
* Non-empty array of rules.
*
* Rules are processed in provided order, first match is taken.
*
* Rules can have the same name. For example, you can have
* separate rules for various keywords and use the same name "keyword".
*/
export type Rules = [
//...
];
Desirable index description: Non-empty array of rules.
Previously mentioned issue of missing description is now fixed, that's nice.
hmm
Is htmlTable
for indexFormat
included in 4.1.1?
If I try to set it - it doesn't fail like with unknown value, but it outputs a list instead.
Sorry - the option was exposed but the logic wasn't merged into the release. It will go into 4.1.2.
What package is the bug related to?
typedoc-plugin-markdown
Describe the issue
Related to #615
Issues I notice with table formatting, in version 4.0.2.
Interface members, unexpected line-breaks
Type alias, unexpected line-break
Function parameters, unexpected line-break
Index, missing description
(expected "Lexer function." in the description column)
Index, unexpected line-break
Index, description trimmed at line-break, no full paragraph, no ellipsis
(expected "String rule - looks for exact string match that can be different from the name of the rule." in the description column) (there is an unexpected line-break instead)
TypeDoc configuration
Expected behavior
No response