-
Notifications
You must be signed in to change notification settings - Fork 142
Add element tagging functionality #467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Yes, that's fine too. Shouldn't we allow multiple tags i.e., Tagged elements are shown by default or hidden by default? |
|
They're always hidden by default unless a matching tag is specified. I'm not sure about multiple tags... Does that mean if a single tag matches, we display the element? |
|
Sounds good.
For this round, yes, we can do that. But eventually we are are going to need a
I prefer to not use site.json vs frontmatter: note that tag filtering need not be site-wide. Ideally, there should be a way to specify it for a group of files. |
I think that it is a good idea going in the direction of allowing MarkBind to be extensible in the future. Separating the core logic with the "additional" features would create a good foundation for such a plugin system. |
|
Changes: Simplified tags: I think we can just use the I left in the front matter functionality - do we want it in? Either way it's only a couple of lines of code changed so it's not a big thing Is having both include and exclude necessary? I think it's sufficient to either include all and the user specifies Regarding the plugin thing, I think that's a great idea. It should be in its own PR though, I'll create another issue. We can migrate other functionalities (like anchors) to plugins too |
While one can be used in place of the other, depending on the reuse context, one is usually more convenient than the other. Sometimes you want to say |
8b436f4 to
20a93a2
Compare
|
Updated |
a14afe2 to
ba27434
Compare
|
Updated |
yamgent
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will need you to resolve the conflicts as the lib -> src thing has been merged recently.
Some more nits in documentation.
2b5c18e to
0f08927
Compare
acjh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested improvements to phrasing and style.
docs/userGuide/usingComponents.md
Outdated
| </frontmatter> | ||
| ``` | ||
|
|
||
| Tags in the `frontmatter` will take precedence over the ones in `site.json`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"front matter"
"
front`matter"`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, edited.
Actually, this precedence order is problematic for reuse. To paraphrase the open-closed principle from OOP, we should be able to extend existing pages (for reuse) without modifying them. i.e., we should be able to reuse a page without modifying its content while overriding its behavior using some external means, such as the |
|
Agreed, |
|
Sure - can change the order. Will change the other one in a separate PR. Updated |
|
Updated |
yamgent
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments about the documentation.
|
Updated |
|
@jamos-tay can you resolve conflict for this PR? Thanks! |
Allow single value tag without list
Clarify heading
76f7d9c to
ad5ec3f
Compare
|
Rebased on master! |
|
@jamos-tay is it possible to override frontmatter tags of a specific page/glob from site.json? Or site.json tags can only apply to the entire site? |
Currently it applies to the entire site only, no way to do it for a particular page. The current overriding mechanism is also rather aggressive atm: I realize that it is not true that we don't lose any functionality for not categorizing tags into different groups. Consider this scenario:
<div tags="level--beginner">
This is how you do Hello World:
<code tags="lang-cs">Console.WriteLine("Hello World");</code>
<code tags="lang-java">System.out.println("Hello World");</code>
</div>
<div tags="level--advanced">
Let's do a refresher. Recall that to print anything, you would use <code tags="lang-cs">Console.WriteLine()</code><code tags="lang-cs">println()</code>.
<question>
How would you print the string "Hello World"?
...
</question>
</div>
<frontmatter>
tags: lang-cs
</frontmatter>
<include src="helloWorld-fragment.mbdf" />
<frontmatter>
tags: lang-java
</frontmatter>
<include src="helloWorld-fragment.mbdf" />I want two different websites: for beginner, and for advanced. Both of these websites will render |
|
@jamos-tay perhaps we can do another iteration for this feature to iron out these rough edges? |
|
Hmm... I think what we can do is a tag merge, i.e. instead of overwriting the frontmatter tags completely we merge them instead. We probably should have done it this way earlier. |
@jamos-tay don't forget this one too. In addition, should we also have a way to specify tags at the point of inclusion, the same way we allow overriding variables at the point of inclusion? |

What is the purpose of this pull request? (put "X" next to an item, remove the rest)
• [X] New feature
Fixes #435
What is the rationale for this request?
The user may want to be able to show/hide certain elements from a page depending on the deploy configuration.
Cited use case:
When generating multiple sites with only slightly differing content, it might be easier to store all the information in one page, and allow the author to show/hide them. For example, if I have a Java tutorial page and a C# tutorial page, the text content can be exactly the same, only the code will differ:
The user can then deploy a Java or a C# version of the site without having two projects.
What changes did you make? (Give an overview)
Functionality implemented based on what was discussed here: #435 (comment)
Tags (
{tagType}--{tagName}) are added to any HTML element.User can specify which tags to include in site.json or frontmatter. Frontmatter takes precedence.
Only elements with tags in site.json are displayed, rest are hidden.
Simplified from
include: { type: 'lang', include: ['java'] }to justinclude: { 'lang': ['java'] }though.Is there anything you'd like reviewers to focus on?
Behavior works according to spec, but I'm wondering if it's a little unintuitive - do we want to mandate categorizing tags into different types (
langetc.) rather than just having general use tags, without the{type}--? I.e.include : ['tag1', 'tag2' ... ]I don't think we lose any functionality by having the latter.