Closed StevenBonePgh closed 3 years ago
In tabbed code sections, the selected language is persisted across pages so that when you move from page to page, the same language is shown for code examples and language-specific text from that point on until you change it again. That would likely break if you introduce tabs with unknown languages values.
I'm not saying it isn't possible, just that it's probably a more involved change than you might think with changes to the presentation style transforms, the presentation style scripts, and the Syntax Component itself. The Syntax Component is what handles the grouping and is unrelated to syntax highlighting which it doesn't do and isn't relevant to grouping.
Based on your response, I created a new project using the template for a syntax generator for 'Ruby'. The documentation and template for Creating a Syntax Filter Generator Component is excellent. I changed the template to derive from SyntaxGeneratorCore
and implemented both required methods (Initialize
and WriteSyntax
) as no-ops. I then put a build dependency on the syntax generator and use a post build step to robocopy (ignore errors) into my .shfbproj folder. This causes SHFB to display 'Ruby' under the Syntax filters and once Ruby is checked, and 'Ruby' is used as the text of the <code language="Ruby">
it will group the samples as necessary. It was rather simple to do once you know where to look,
I expected to have some form of an issue with the 'Syntax' on method documentation pages where 'Ruby' would show up as an empty tab, but there appears to be no such issue or side-effect. The only place 'Ruby' appears on the output is on the conceptual content page with the sample.
Unless you see a concern or issue with my approach here, I'll close this issue.
That should work. The only thing to check is that if you select a Ruby tab and then go to other topics, it still behaves as expected with regard to which tab is shown as the default in the new topic on other grouped code sections.
You can leave this open as I may look into it further. Based on what you did it may be possible to create a generic no-op syntax writer that can be used to handle grouping of any unrecognized language IDs. I'll give it some thought.
Combined with #868
I was attempting to get grouping of samples for various languages to work and ran into the same issue as #85 where they were being stacked and not tabbed (I posted the solution for that issue is posted there). I also saw issue #315 where the desire was to tab-group some unrelated items outside of code examples together.
My use case is to show similar code examples with tabs for several languages, including ones without official language syntax filters. I don't care so much about syntax highlighting, but I'd still like to see the examples in unknown languages tabbed.
One specific example is showing how a task can be done in multiple languages - think of a RESTful API where headers need to be set with Content-MD5, or perhaps HMAC signatures. While I provide examples in C#, many consumers are using languages such as Java, Ruby, Perl, etc. where specific examples on how to do it in various languages would be helpful. It would be a great space-saver to group them.
If a modification was made to SHFB to allow grouping of unknown languages - for instance a
code
element with an unsupportedlanguage
element using the text of the language element on the tab and no syntax highlighting, this would suffice for my use case. It would also be applicable to #315 - notwithstanding localization issues for that use case. At least programming language names use the same word in all languages.