question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Idea: More flexible styling of blockquotes and lists (e.g. for card templates)

See original GitHub issue

This is a suggestion inspired by #212@ryantheleach’s request for printable card templates in the Homebrewery. @wrdclark did some great work mocking up some styles for cards based on <div class='card'>, but unfortunately, as @vlos observed, deeply nested <div> tags tend to switch the markdown parser into HTML mode, and thus lose the ability to use nice markdown formatting.

Looking into this, I discovered @stolksdorf’s cool trick of styling lists differently if they immediately follow a <hr>, and I couldn’t help thinking that this would also be useful for cards, allowing us to nest their content in a <blockquote> and not a <div> and thus preserve markdown formatting.

Unfortunately, there’s only one kind of <hr/> tag, and so we need something else to attach styling to. This is where we can exploit two facts: Firstly, <h6> are currently unstyled and hence almost definitely unused; secondly, marked (our Markdown parser) generates IDs for the <h6> tags based on the text of the heading. To make a long story short, here’s a bit of markup:

###### card
> ### Goblin
>
> <img src="http://i.imgur.com/ET6Hp6D.png" style="height: 5cm;"/>
>___
>|STR|DEX|CON|INT|WIS|CHA|
>|:---:|:---:|:---:|:---:|:---:|:---:|
>|8 (-1)|14 (+2)|10 (+0)|10 (+0)|8 (-1)|8 (-1)|
>___
> <div class='descriptive'>
> - All markdown formatting works.
> - Even nested lists.
>   - And sublists.
> </div>
>

And here’s how it could render: image.

The key trick is to write selectors that begin with h6[id|='card'] + blockquote, meaning “the blockquote immediately following the <h6> tag whose ID starts with card”. In particular, this also allows different styles of card – ###### card back could, for example, rotate the card by 180 degrees, so that you can simply fold to get a standee/tent.

For a more complete picture, including the CSS in its current form, please see this brew. (Full disclosure: Due to what seems like a Chrome bug, currently the rotated cards are not displayed in the PDF view in columns after the first (even to get them to render in the browser, I had to add the spurious translateZ(0) to the transform). Any suggestions for what may be going wrong would be very welcome.)

Once I got this far, I realized that this also has the potential of cutting down on some boilerplate. For example, when defining a spell, there’s the spell kind plus four other properties that always appear in the same order. The current template includes them in the markdown that the user writes, but conceivably we could hide them in the stylesheet and simply require the user to enter the things that actually vary:

###### spell
#### Illusionary Transfiguration of the Babysitter
- 7th-level transmutation
- 1 action
- 60 feet
- M (discarded gum wrapper, a small doll, a crushed button worth at least 1cp)
- Instantaneous
- A flame, equivalent in brightness to a torch, springs from from an object that you touch. 
  The effect look like a regular flame, but it creates no heat and doesn't use oxygen. 
  A *continual flame* can be covered or hidden but not smothered or quenched.

For a stylesheet that makes this equivalent to the current spell snippet, see this brew. Similarly, when defining class features, there are sections on hit points and proficiencies that are very formulaic; see this brew for a possible way of condensing that.

It seems that using <h6> headings plus blockquotes or lists in this way allows us to style markdown in radically different ways without requiring too many contortions. What do you think?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
Gazook89commented, Sep 17, 2021

@ryantheleach if you are looking for MtG cards, here is a brew I put together after lots of experimenting. However, this is pre-v3 which isn’t really a problem because we kept the Legacy renderer as well. I do have other brew documents that are different attempts to make cards (such as this, and this) as well.

I’m not going to say it’s 100% straightforward, but it is an option and does demonstrate the flexibility of homebrewery (even before v3).

That said, further development can happen for different layouts in the future as @calculuschild says and hopefully it just gets easier.

1reaction
calculuschildcommented, Sep 17, 2021

@ryantheleach The core issue here was resolved (more flexible styling) and you can see several examples by looking at the Snippets available in V3, as well as taking a look at the V3 welcome page here: https://homebrewery.naturalcrit.com/v3_preview

We have not officially created a card layout if that is what you are looking for, but that may be something we add in the future, and you can certainly ask around on the subreddit https://www.reddit.com/r/homebrewery because I know some people have done things like that before.

Read more comments on GitHub >

github_iconTop Results From Across the Web

29 Unique & Creative CSS Blockquote Inspirations For Text ...
The first on our list of CSS blockquotes example leans more towards the more stylish and unique approach. It is based off a...
Read more >
30+ Free Blockquote (Pull Quote) HTML Templates
Best collection of free blockquote (cite tag) HTML templates. These pull quote designs are using bootstrap and CSS which enables you to ...
Read more >
Bootstrap Quote - free examples, templates & tutorial
Responsive Quotes built with Bootstrap 5. HTML & CSS. Quote boxes with quote symbol, blockquotes, quote carousel slider, various quote styles with HTML ......
Read more >
Block Quotes and Pull Quotes: Examples and Good Practices
They can be styled using graphics, CSS and a little bit of JavaScript. Sometimes, creative dynamic solutions can be applied as well.
Read more >
How to Style Block Quotes with CSS - Web Design Tutorial
In this video tutorial I'll be showing you how to style block quotes with CSS - a pure CSS solution (incl. the 'double...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found