Skip to content
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

Add Icon and Media Support to List - Resolves #906 and #2272 #2316

Merged
merged 101 commits into from
Aug 5, 2023
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
e485b3d
Add support for fontawesome
SPWwj Jun 28, 2023
3572978
Complete list level config
SPWwj Jun 28, 2023
3b6f63e
Add element level config
SPWwj Jun 28, 2023
fb80534
Icon List Usage Documentation Update
SPWwj Jun 30, 2023
f72b476
Update image for icon list doc
SPWwj Jun 30, 2023
afba2c1
Add demo for medial list
SPWwj Jun 30, 2023
262dd6f
Add demo size config
SPWwj Jun 30, 2023
10b7a0e
Update list doc to by pass include render bug
SPWwj Jun 30, 2023
ce43e24
Improve the UG section on lists.
SPWwj Jul 2, 2023
cd0a69e
Update image icon to use padding
SPWwj Jul 2, 2023
21dd1a4
Fix lint errors
SPWwj Jul 2, 2023
3588747
Adhere support to markbind icons
SPWwj Jul 7, 2023
81183d0
Migrate markdown-it-emoji-fixed to ts
SPWwj Jul 7, 2023
59caa54
Fix not support for fa icon
SPWwj Jul 7, 2023
ef18aa1
Convert size to width and height
SPWwj Jul 8, 2023
4fc6ff7
Update icon list from first default to waterfall
SPWwj Jul 8, 2023
4d107b9
Fix lint error
SPWwj Jul 8, 2023
a14d35a
Fix markdown-it-emoji typing
SPWwj Jul 8, 2023
eca3576
Merge branch 'master' into branch-media
SPWwj Jul 8, 2023
2548b86
Add markdown-it-emoji-fixed.d.ts
SPWwj Jul 8, 2023
050ebf1
Fix import markdown-it-emoji-fixed error
SPWwj Jul 10, 2023
d960ab4
Revise docs for clearer icon list explanation
SPWwj Jul 11, 2023
82da76c
Fix lint error for icon style
SPWwj Jul 11, 2023
03b2c35
Refractor markdown-it-icons
SPWwj Jul 12, 2023
1c7806e
Add icon syntax auto correct
SPWwj Jul 12, 2023
c23485b
Switch from Low-Level DOM to Cheerio API
SPWwj Jul 12, 2023
6bfa00f
Complete waterfall model logic
SPWwj Jul 13, 2023
59c1473
Merge branch 'master' into branch-media
SPWwj Jul 13, 2023
1b031ac
Add Attribute Waterfall Logic for Icon List
SPWwj Jul 13, 2023
a61c5b3
Merge branch 'branch-media' of https://github.com/SPWwj/markbind into…
SPWwj Jul 13, 2023
4404c3f
Update icon list doc layout
SPWwj Jul 13, 2023
f73713b
Fix waterfall logic incorrect behaviour
SPWwj Jul 14, 2023
a4d5c16
Update doc for icon list
SPWwj Jul 14, 2023
56522f9
Fix lint error
SPWwj Jul 14, 2023
cf178b9
Refine doc for icon list
SPWwj Jul 15, 2023
3d435fa
Fix lint error
SPWwj Jul 15, 2023
35be3c3
Add support for fontawesome
SPWwj Jun 28, 2023
42052d5
Complete list level config
SPWwj Jun 28, 2023
73a4bfc
Add element level config
SPWwj Jun 28, 2023
3483691
Icon List Usage Documentation Update
SPWwj Jun 30, 2023
3b3ce04
Update image for icon list doc
SPWwj Jun 30, 2023
61a83ad
Add demo for medial list
SPWwj Jun 30, 2023
319ccc0
Add demo size config
SPWwj Jun 30, 2023
7367609
Update list doc to by pass include render bug
SPWwj Jun 30, 2023
4cf49f2
Improve the UG section on lists.
SPWwj Jul 2, 2023
7eaff80
Update image icon to use padding
SPWwj Jul 2, 2023
982aa43
Fix lint errors
SPWwj Jul 2, 2023
58ac61a
Adhere support to markbind icons
SPWwj Jul 7, 2023
d94f448
Migrate markdown-it-emoji-fixed to ts
SPWwj Jul 7, 2023
1138459
Fix not support for fa icon
SPWwj Jul 7, 2023
f703ecc
Convert size to width and height
SPWwj Jul 8, 2023
319f2a8
Update icon list from first default to waterfall
SPWwj Jul 8, 2023
c5d98e3
Fix lint error
SPWwj Jul 8, 2023
eea1431
Fix markdown-it-emoji typing
SPWwj Jul 8, 2023
09ba42e
Add markdown-it-emoji-fixed.d.ts
SPWwj Jul 8, 2023
d61e300
Fix import markdown-it-emoji-fixed error
SPWwj Jul 10, 2023
924c90c
Revise docs for clearer icon list explanation
SPWwj Jul 11, 2023
77d4431
Fix lint error for icon style
SPWwj Jul 11, 2023
25662e1
Refractor markdown-it-icons
SPWwj Jul 12, 2023
097a23e
Add icon syntax auto correct
SPWwj Jul 12, 2023
481228b
Switch from Low-Level DOM to Cheerio API
SPWwj Jul 12, 2023
a0031d8
Complete waterfall model logic
SPWwj Jul 13, 2023
44929ac
Add Attribute Waterfall Logic for Icon List
SPWwj Jul 13, 2023
8d6b7a6
Update icon list doc layout
SPWwj Jul 13, 2023
0db4166
Fix waterfall logic incorrect behaviour
SPWwj Jul 14, 2023
eb5a351
Update doc for icon list
SPWwj Jul 14, 2023
541ef91
Fix lint error
SPWwj Jul 14, 2023
2d1f16d
Refine doc for icon list
SPWwj Jul 15, 2023
04d538e
Fix lint error
SPWwj Jul 15, 2023
6b65bde
Merge branch 'branch-media' of https://github.com/SPWwj/markbind into…
SPWwj Jul 18, 2023
e60535b
Improve code quality.
SPWwj Jul 18, 2023
e46f500
Bfs for waterfall
SPWwj Jul 19, 2023
68632d8
Update to a more specific icon attribute name
SPWwj Jul 19, 2023
2d30fc1
Update test
SPWwj Jul 19, 2023
5713956
Merge branch 'master' into branch-media
SPWwj Jul 19, 2023
f534d69
Add test
SPWwj Jul 19, 2023
0e0aa0d
Update markdown-it-icons to include comments
SPWwj Jul 19, 2023
3d0f2f1
Update doc to add more complicated example
SPWwj Jul 19, 2023
113251f
Prevent reprocessing waterfallModel
SPWwj Jul 19, 2023
309a556
Employ regular object export for markdownItPlugin
SPWwj Jul 23, 2023
4768989
Set image as default fallback for icon
SPWwj Jul 23, 2023
a541746
Clean up the redundant initialization
SPWwj Jul 23, 2023
c5c901a
Update dfs
SPWwj Jul 23, 2023
d76db28
Improved code quality
SPWwj Jul 30, 2023
c22cda1
Update test
SPWwj Jul 30, 2023
cf0f67e
Add more test
SPWwj Jul 30, 2023
96c3332
Update comments
SPWwj Jul 30, 2023
2ba867e
Merge branch 'master' into branch-media
SPWwj Jul 30, 2023
71b66d0
Add flex-shrink to span node
SPWwj Jul 30, 2023
9f65971
Merge branch 'branch-media' of https://github.com/SPWwj/markbind into…
SPWwj Jul 30, 2023
dd979b5
Update test case
SPWwj Jul 30, 2023
137b52b
Update comment
SPWwj Jul 31, 2023
45e4236
Fix lint error
SPWwj Jul 31, 2023
fad29bb
Improve doc for customize list
SPWwj Aug 4, 2023
b005fc3
Remove unused image
SPWwj Aug 4, 2023
46081cc
Fix list doc nits
SPWwj Aug 4, 2023
0273b03
Rename to CustomListIconProcessor
SPWwj Aug 5, 2023
607b70d
Merge branch 'MarkBind:master' into branch-media
SPWwj Aug 5, 2023
df32b5f
Update doc
SPWwj Aug 5, 2023
9e0e616
Merge branch 'branch-media' of https://github.com/SPWwj/markbind into…
SPWwj Aug 5, 2023
5f8d782
Update list icon paragraph description
SPWwj Aug 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added docs/images/conclusion-d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/detailed-d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/highlights-d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/overview-d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
124 changes: 124 additions & 0 deletions docs/userGuide/syntax/lists.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,127 @@ first number
- [x] Item 4
- ( ) Item 5
</div>
damithc marked this conversation as resolved.
Show resolved Hide resolved

SPWwj marked this conversation as resolved.
Show resolved Hide resolved
****Customizing the list appearance:****

SPWwj marked this conversation as resolved.
Show resolved Hide resolved
**To customize list icons, add the configuration `{icon="icon-name"}` after a specific list item**

<include src="codeAndOutput.md" boilerplate >
<variable name="highlightStyle">markdown</variable>
<variable name="code">
* Item 1 {icon="glyphicon-education"}
* Item 2
* Item 2.1 {icon="fas-file-code"}
* Item 2.2
* Item 3 {icon="fas-code-branch"}
* Item 3.1
* Item 4 {icon="octicon-git-pull-request"}
* Item 4.1 {icon="mif-perm-media"}
* Item 5 {icon="glyphicon-education"}
* Item 5.1 {icon="notebook_with_decorative_cover"}
</variable>
</include>

damithc marked this conversation as resolved.
Show resolved Hide resolved
1. If an item has a specified icon, that icon will be used for it and for subsequent items at that level.
2. If any item at a level is customized, the first item at that level must also be customized. If not, the list will be invalidated.
3. You can use any of the icons supported by MarkBind (e.g., Font Awesome, Octicons, Glyphicons and Emojis) as the icon of a list item.
SPWwj marked this conversation as resolved.
Show resolved Hide resolved
4. When using icons, omit the `::` around the icon name (e.g., use `{icon="emoji"}` instead of `{icon=":emoji:"}`).
SPWwj marked this conversation as resolved.
Show resolved Hide resolved

**You can adjust the icon's size by using the `size` attribute.**

<include src="codeAndOutput.md" boilerplate >
<variable name="highlightStyle">markdown</variable>
<variable name="code">

* Item 1 {icon="glyphicon-education" size="35px"}
* Item 2 {icon="glyphicon-education" size="4rem"}
* Item 3 {icon="glyphicon-education" size="5em"}
SPWwj marked this conversation as resolved.
Show resolved Hide resolved

</variable>
</include>
damithc marked this conversation as resolved.
Show resolved Hide resolved
damithc marked this conversation as resolved.
Show resolved Hide resolved

You can utilize any CSS size unit. For more details, refer to the guide on [CSS size units.](https://www.w3schools.com/cssref/css_units.php).
SPWwj marked this conversation as resolved.
Show resolved Hide resolved

**You can use image as icon.**
SPWwj marked this conversation as resolved.
Show resolved Hide resolved

<include src="codeAndOutput.md" boilerplate >
<variable name="highlightStyle">markdown</variable>
<variable name="code">

* Item 1 {icon="/images/deer.jpg" width="30px" height="17px"}
* Item 2 {icon="/images/deer.jpg" width="60px" height="34px"}
* Item 3 {icon="/images/deer.jpg" width="90px" height="51px"}
* Item 4 {icon="/images/deer.jpg" width="120px" height="68px"}
* Item 5 {icon="/images/deer.jpg" width="150px" height="84px"}

</variable>
</include>

The `Width` and `height` is use to specific the dimension for the image icon, similar to size it support all css size units: [CSS Units](https://www.w3schools.com/cssref/css_units.php)
If the width and height are unspecified, the image's default dimensions will be used.
SPWwj marked this conversation as resolved.
Show resolved Hide resolved

**The icon's appearance can be further customized by adding a `class` attribute.**

<div id="main-example-markbind">

<include src="codeAndOutput.md" boilerplate >
<variable name="highlightStyle">markdown</variable>
<variable name="code">
* Item 1 <br>
Item 1 line 2{icon="/images/deer.jpg" width="60px" height="60px" height="17px" class="rounded"}
* Item 2
Item 2 Continue
* Item 2.1 {icon="fas-code-branch" class="text-success"}
* Item 2.2 {class="text-danger"}
SPWwj marked this conversation as resolved.
Show resolved Hide resolved
* Item 2.3
* Item 3
* Item 3.1
* Item 3.2 {class="text-primary"}
* Item 3.3 {icon="fas-file-code" class="text-warning"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can provide a way to use text instead of an icon. e.g.,

Step 1: blah blah
        blah blah

Step 2: blah blah
        blah blah

That's like numbered lists already, except the auto-incrementing the number. Anyway, can leave as a future enhancement.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is feasible. The syntax for such a list would be {text="Step 2", class="text-warning"}. Since we can't reuse the icon attribute, the text will collide with the emoji name.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sound good. As mentioned, we can leave it as a future enhancement.

* Item 3.4
* Item 4
* Item 4.1 {icon="x" class="badge border border-primary rounded-pill mb-1 border-danger"}
* Item 4.2 {icon="exclamation"}
</variable>
</include>
SPWwj marked this conversation as resolved.
Show resolved Hide resolved

damithc marked this conversation as resolved.
Show resolved Hide resolved
damithc marked this conversation as resolved.
Show resolved Hide resolved
1. Once a class attribute is assigned to an icon, it will continue apply to icons at the same level, until it is overridden by a different class attribute (e.g., from Item 2.1 to Item 2.2, and so on to Item 3.2).
2. All standard Markdown rules will apply to the icon list (e.g., Item 1 and Item 2 to create a single item using multiple lines).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm... we use a new term icon list here. I don't mind adopting that (or some other name e.g., Fancy Lists) as our own standard name for this kind of customized lists but that needs to be upfront e.g., in that case this whole thing can be put under a heading called icon lists, instead of Customizing the list appearance. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The more I think about it, the more I feel like this feature deserves its own name, such as Fancy Lists. Most other similar tools have something comparable, so we can name it as we wish.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The icon list is an extension to the current unordered lists. Adding a new section for the icon list might not be visually appealing in the page navigation.

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It need not appear as a separate item. We can just replace Customizing the list appearance with Fancy Lists (without making it a pageNav heading) and use that term from that point to refer to customized lists.

More generally, either we choose a name for this feature and use it consistently throughout, or not use a name at all, referring to the feature as 'customizing' instead. Currently, we throw in the term icon list suddenly in the middle of the feature description.

</div>


**You can apply Markdown's heading and paragraph syntax within the list.**

<include src="codeAndOutput.md" boilerplate >
<variable name="highlightStyle">markdown</variable>
<variable name="code">

* #### Heading 1: Overview {icon="/images/overview-d.png" width="65px" class="rounded"}

Content 1: This section provides a summary of the document or topic.
It sets the context and purpose of the content to follow.

* ##### Heading 1.1: Highlights {icon="/images/highlights-d.png" width="65px" class="rounded"}

Content 1.1: Here we summarize the key points, findings, or features of the main topic.
This could include important data, outcomes, or insights.

* #### Heading 2: Detailed Description {icon="/images/detailed-d.png" width="65px" class="rounded"}

Content 2: This section delves deeper into the topic, offering comprehensive information and detailed explanations.
It might also include evidence, examples, or justifications.

* #### Heading 3: Conclusion {icon="/images/conclusion-d.png" width="65px" class="rounded"}

Content 3: The conclusion draws together the main threads of the topic,
summarizing the central points and their implications.

* ##### Heading 3.1: Final Thoughts

Content 3.1: This is a place for final reflections, recommendations, or a look towards future developments or trends.

</variable>
SPWwj marked this conversation as resolved.
Show resolved Hide resolved
</include>
SPWwj marked this conversation as resolved.
Show resolved Hide resolved

1. Icon specifications should be attached only to the first element of a list item (for the example above, the icon specification should be attached to the heading, not the block of text below the heading).
2. A blank line must separate a heading from the content that follows it.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions packages/core/src/html/NodeProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { highlightCodeBlock, setCodeLineNumbers } from './codeblockProcessor';
import { setHeadingId, assignPanelId } from './headerProcessor';
import { FootnoteProcessor } from './FootnoteProcessor';
import { MbNode, NodeOrText, TextElement } from '../utils/node';
import { processUlNode } from './UlNodeProcessor';

const fm = require('fastmatter');

Expand Down Expand Up @@ -195,6 +196,9 @@ export class NodeProcessor {
case 'question':
this.mdAttributeRenderer.processQuestion(node);
break;
case 'ul':
processUlNode(node);
SPWwj marked this conversation as resolved.
Show resolved Hide resolved
break;
case 'q-option':
this.mdAttributeRenderer.processQOption(node);
break;
Expand Down
Loading