So if I understand correctly, you want to customize a few tables in your post but leave the default output for tables the same? Then what you’re looking for is shortcodes.
That should not be too hard. I think the hardest is Markdown tables allow for headings by having dashes on the next line. Supporting this feature means you can’t just parse the markdown and generate HTML at the same time; you would need to parse the second line before being able to display the first line.
Also, a nice HTML5 trick that may help you out testing things out before you change your CSS: the <style> tag can take a scoped="scoped" param so that it may be placed within the HTML body, and only applies to the style tag’s parent and siblings. This allows you to have both HTML and CSS right next to you when trying things out
Actually, forget my previous comment. You don’t have to parse the content, you can use the markdownify function on the content like so:
{{ .Inner | markdownify }}
Then that’s some basic HTML/CSS concern to match only tables within your shortcode div with .table table and .table td. My advice: pick a more specific class name for your special tables, otherwise you may not understand by reading your CSS what this .table class actually is.
What I would need is a pool of shortcodes to “steal” from.
Currently I’ve to browse the themes, this forum and tplimpl/template_embedded.go for inspiration.
Why not leave the shortcodes to the themes an projects but provide the authors with many examples.
btw: a generic classify would not hardcode div since span with classes may be useful as well (as long there are no block’s inside).
are you aware that in that specific sample above you should write .table in your css? you are giving a class table to the table, then defining all tables by using table in css. only .table will add the special design to those shortcoded tables.
edit: or to be specific: .table table will apply the 100% width.
A pool of shortcodes is a great idea. A repo on Github is my idea.
A markdown file with the shortcode and an explanation of which task the shortcode fulfills. The question is, how do we categorize and catalog the shortcodes?
It should be possible to have “shortcode pack” themes, and then the theme.toml in those can specify the tags as appropriate. I am eagerly waiting for that feature to be out
@rrastik Please do not keep resurrecting old posts. Also, this is now the second time you are posting the same link. Please do not keep posting the same link.