mpetrovich / stylemark

Generate interactive style guides from Markdown.
MIT License
218 stars 35 forks source link

Dedicated markdown file not working? #28

Closed feebala closed 6 years ago

feebala commented 6 years ago

I'm using a dedicated markdown file in the directory I'm watching to generate the styleguide - but it's not generating the guide. It registers that a change has been made to the file (so I know it's watching the .markdown file) but nothing updates on the front end. The log doesn't show any errors, i.e. in terminal, so I'm not sure if this is a bug or an issue with the markdown file itself...

My code for the file looks like a series of blocks like this:

---
name: Default Table
category: Tables
---

Tables in angular/webapps should only be used for tabular data.

```table-default.html
<table class="table default">
    <thead>
        <th>Table Header</th>
        <th>Header 2</th>
        <th>Actions</th>
    </thead>

    <tbody>
        <tr>
            <td>Row 1 cell 1</td>
            <td>Row 1 cell 2</td>
            <td><button>Edit</button></td>
        </tr>
        <tr>
            <td>Row 2 cell 1</td>
            <td>Row 2 cell 2</td>
            <td><button>Edit</button></td>
        </tr>
        <tr>
            <td>Row 3 cell 1</td>
            <td>Row 3 cell 2</td>
            <td><button>Edit</button></td>
        </tr>
    </tbody>

</table>```
feebala commented 6 years ago

Note that the styleguide was generating perfectly when I had the markdown inside my .scss files, but it was getting unwieldy and messy, so a dedicated file made more sense.

feebala commented 6 years ago

Last note: I got it working again (Very fussy on the spacing!) but only the first block renders correctly - Can a single markdown file not contain more than one component/block?

mpetrovich commented 6 years ago

I'm able to recreate the problem based on your example above. The issue is that the closing backticks (```) need to be on their own line. Once you do that, it works as expected.

Good:

</table>
```

Bad:

</table>```
feebala commented 6 years ago

I should have noted - The closing backticks are on their own line in my code. They're inline with the closing tag here only because it was the only way to include them here (I'd need a double set of closing backticks to emulate what I have in my markdown file, and it was rendering weirdly with the double set on individual lines.)

mpetrovich commented 6 years ago

You can use triple tildes ~~~ instead of triple backticks on GitHub. They’re equivalent and useful for cases such as yours.

feebala commented 6 years ago

You can use triple tildes ~~~ instead of triple backticks on GitHub. They’re equivalent and useful for cases such as yours.

Good to know! However, my original issue is still a problem - namely that a markdown file with multiple blocks (even with the closing back ticks on their own line) doesn't generate the correctly formatted output.

feebala commented 6 years ago

Here's the full markdown file code for reference: https://codepen.io/feebala/pen/qoLgqP

mpetrovich commented 6 years ago

OK, I'll reopen and investigate further.

mpetrovich commented 6 years ago

Oh, now I see what you're trying to achieve. Multiple components—not code blocks—per markdown file.

Unfortunately, multiple components per Markdown file is not supported at this time, and there are currently no plans to support it in the future. This is because we use Markdown front matter to identify a component, and front matter is a strictly one-per-file block at the beginning of a Markdown file.

In contrast, documenting multiple components in the same file is supported when you're documenting them as source code comments (ie. in your CSS/JS files).

For your situation, you'd need to split out your components into individual Markdown files—one per component.

feebala commented 6 years ago

Ah ok. Thanks for clarifying and taking the time to investigate 👍