Open Yakyyaky opened 3 months ago
Thanks for the super detailed description. It can be solved by "custom section number format" (#1380) although I guess it won't get implemented in the near future 😂.
The code is simple
so a workaround is to modify the $HOME/.vscode/extensions/yzhang.markdown-all-in-one-3.6.2/dist\node/main.js
(searching e=>`${a[e+r-1]}.`
)
- e=>`${a[e+r-1]}.`
+ e=>`Section ${a[e+r-1]}.`
Then VS Code may warn you that the extension file is corrupted but it should be okay. This change will persist until the next update of this extension (at least a couple of months later 😂).
Thanks for the fast response.
I've tried your suggest and got this.
# ABC 1. Introduction
# ABC 2. Help
## ABC 2.ABC 1. Sub Help
Thankfully, you pointed to the source code. So I was able to work out a solution that worked for me. The final replacement is I had was:
- const s=[...Array(n-r+1).keys()].map((e=>`${a[e+r-1]}.`)).join("")
+ const s='Section ' + [...Array(n-r+1).keys()].map((e=>`${a[e+r-1]}.`)).join("")
I've also made updates to remove the "Section " so that remove removeSectionNumbers
from your tos.ts
will work correctly as well.
This was done by replacing the min js for removeSectionNumbers
, that references
https://github.com/yzhang-gh/vscode-markdown/blob/895dfe3a8a78f41aba59063cecec82e8c29196ac/src/toc.ts#L174-L176
In the min file it was something along the following.
- a.replace(/^(\s{0,3}#+ +)((?:\d{1,9}\.)* )?(.*)/,((e,t,n,r)=>`${t}${r}`)):a.replace(/^(\s{0,3})((?:\d{1,9}\.)* )?(.*)/,((e,t,n,r)=>`${t}${r}`));
+ a.replace(/^(\s{0,3}#+ +)Section ((?:\d{1,9}\.)* )?(.*)/,((e,t,n,r)=>`${t}${r}`)):a.replace(/^(\s{0,3})Section ((?:\d{1,9}\.)* )?(.*)/,((e,t,n,r)=>`${t}${r}`))
And this allowed me to add and remove headers with the "Section
" prefix.
However, The Add/Update section header was cummulatively adding Section prefix, which meant I couldn't call it recursively. Since I was able to update removeSectionNumbers
, it was adequate, as I just have to remove and add manually instead of relying on Add/Update section header.
I'm happy with waiting for the next release, and this workaround bridge what I need for the moment.
Please close the issue if you see fit. Thanks for all your help.
Thanks for the update.
Proposal
I've been going through some of the issues that plague Azure Devops's wiki and the TOC. As an alternate solution to the issue with Azure devops treating # as task item. I was hoping that we can have prefixes to Add/Update section header function.
If there's already a solution to this, I'm happy to learn.
Example
Example doc with sectioning:
Current output as Github (default) slugs:
This is greats, unfortunately just doesn't render the links correct in azure devops due to the aforementioned # issue.
Current output AzureDevops slugs
While this works, it is practically unreadable, especially when you have to reference the headings again or when you have to fix heading reference due to heading name changes.
Personally, I definitely prefer the github style in favour of maintaining readability. As a workaround/alternative solution. I would like to have section prefix. So when we generate the ADD/Update section headers. It will generate the following instead.
Which then generates the TOC like so
Outcome Benefits
For my specific use case, it provides the following advantage
Others may have usages for section header prefixes being auto generated. For example they may be writing requirements doc
When cross referencing documents, it's nice to see these headings presented as such.
Background details
802
1383
Thank you
Thanks for reading my request and more importantly the very useful extension to help with markdown writing.