Hexo markdown + bulma css - css

I am building static blog site with Hexo.
Now I want to use Bulma to make design easy.
But I wonder how I can call class name from markdown.
If markdown’s # or ## automatically link to Bulma’s class ‘title’ it would be nice.

I am not sure whether the following answer will work as I haven't tried it. But it will give you a good starting point.
First replace the default markdown renderer engine (marked) with hexo-renderer-markdown-it Link
npm un hexo-renderer-marked --save
npm i hexo-renderer-markdown-it --save
Then add the following in _config.yml
markdown: 'default'
For more infomation on values of markdown refer Simple Configuration page.
We can add more options to the _config.yml file.
All options along with explanations can be found Advanced Configuration page
Example Config
# Markdown-it config
## Docs: https://github.com/celsomiranda/hexo-renderer-markdown-it/wiki
markdown:
render:
html: true
xhtmlOut: false
breaks: true
linkify: true
typographer: true
quotes: '“”‘’'
plugins:
- markdown-it-abbr
- markdown-it-footnote
- markdown-it-ins
- markdown-it-sub
- markdown-it-sup
- markdown-it-attrs
anchors:
level: 2
collisionSuffix: 'v'
permalink: true
permalinkClass: header-anchor
permalinkSymbol: ¶
The option which we are interested is the plugin option.
After some research, I found a plugin markdown-it-attrs that can add class attribute as well as other attributes that we normally add, to markdown components
Example input:
# header {.style-me}
paragraph {data-toggle=modal}
Output:
<h1 class="style-me">header</h1>
<p data-toggle="modal">paragraph</p>
Works with inline elements too:
paragraph *style me*{.red} more text
Output:
<p>paragraph <em class="red">style me</em> more text</p>
More examples on plugin page
Add the plugin name in the plugin section of the _config.yml file

Related

How to embed a bookdown gitbook in a quarto website (as a navbar item)?

I have a quarto website and a .html file of a gitbook made with bookdown (located in a subfolder called _notes of the quarto website). How can I embed this gitbook within the quarto website?
The source code of the quarto website is available at: https://github.com/lnalborczyk/IMSB2022
The rendered version of the website (rendered via Github pages) is available at: https://www.barelysignificant.com/IMSB2022/
Now, I would like to redirect to the bookdown gitbook (i.e., the index.html file located in _notes/docs/) when I click on "Notes" in the navbar. Therefore, I have added the following command in my navbar options in _quarto.yml:
navbar:
pinned: true
search: true
background: "#1c5253"
right:
- syllabus.qmd
- planning.qmd
- content/index.qmd
- resources.qmd
- install.qmd
- text: "Notes"
href: "_notes/docs/index.html"
And also added the bookdown folder as a resource using:
resources:
- "files/"
- "_notes/docs/"
This works locally (i.e., via "preview website"), but fails when rendering via Github pages (i.e., it gives a 404 error message).
Any idea on how to make it work online?
Thank you for your help!
Ladislas
OK, just found a solution. The problem came from the "_" prefix in my "_notes/docs", which seems to be interpreted by Github Pages / Jekyll as "do not build this file" (e.g., https://docs.github.com/en/pages/setting-up-a-github-pages-site-with-jekyll/about-github-pages-and-jekyll).
Two solutions: either remove the "_" prefix in "docs/notes" (after rendering the website with Quarto) or (the solution I went for) output the bookdown gitbook directly in a folder at the root of the Quarto website in a folder that does not contain a "" prefix, such as "notes", then adding this folder to the resources in _quarto.yml (as I have done here: https://github.com/lnalborczyk/IMSB2022).
Just sharing this in case it can help others!

Add code to Bookdown gitbook template before TOC

I'm creating a gitbook using bookdown, and the designer wants to put a banner at the top of the book, that is, across the entire page above both the TOC and the chapter text.
If I use the before_body attribute in the YAML, bookdown inserts the code after the TOC, so the banner is only at the top of the chapter. Gitbook doesn't seem to allow for the template: attribute.
Any suggestions for how I can squeeze a line of HTML right after the < body > tag to make my designer happy? :)
I managed to solve this myself--it turns out that although officially the gitbook theme doesn't allow the template: attribute, in practice it does. So I just grabbed the existing template, hard-coded my banner after the < body > tag, and referenced my new template in the YAML. I hope this is helpful for anybody else who runs into this problem!

Automatically collapsing sidebar of R Bookdown website

It is critical that people reading my Bookdown project do not skip chapters. While it is explicitly stated in the document, further discouraging this by automatically collapsing the sidebar would be really helpful :o)
According to this Github issue there is no default explicit option to do this, but is there any other way?
Welcome to stackoverflow!
Using e.g. the inspect feature of Chrome on a bookdown::gitbook you see that the first element in the DOM after <body> is a <div> which 'contains' the whole book. This <div> has multiple classes, one of them is with-summary and this is the one you'd like to remove.
I think the quickest way to do this is jusing jquery:
Set up an HTML file
header.html
<script>
window.addEventListener("DOMContentLoaded", function(){
$("div").first().removeClass("with-summary");
});
</script>
Include the file in the document header using the YAML option includes in your
.Rmd
---
title: "My Title"
output:
bookdown::gitbook:
includes:
in_header: header.html
---
After the page load, the jquery function will pick the first <div> element in the DOM and remove the class. Note that this will hide the sidebar if the user navigates to another chapter, too.

How to quickly create <div> classes in VSCode

Generally new to web design and watching some tutorials on creating some backend for a project, getting really tired of writing out the manually, I see youtubers do .classname and then the class with the div appears, but for some reason it isn't working for me? Any help would be appreciated.
Also, would it be easier to switch to Sublime, my buddies think that it is the way to go.
Cheers.
Go to settings
Go to emmet under the Extensions section.
Click on 'Edit in settings.json'.
Write the following inside the 'emmet.includeLanguages' tag. Otherwise, paste the whole statement.
"emmet.includeLanguages": { "javascript":"javascriptreact" }
Save the settings.json file.
Those videos are likely using emmet. VS Code includes built-in support for emmet completions in html files. For example, typing .classname in an html file will trigger an emmet suggestion that expands to <div class="classname"></div> when you accept it
If you do not see this working:
Make sure the document is in the html language mode
Try manually triggering suggestions after .classname using ctrl+space
Make sure you have not disabled Emmet
I tried everything written in the answers but it wouldnt work, I had to do the following;
go to settings in the bottom left, search for 'emmet'
scroll down to and tick:
'Trigger expansions on Tab'
then it works by typing .divClassName + Tab
Check out this Cheat Sheet for VSC:
Cheat sheet for VSC
Ensure that VScode recognises your file as HTML5 or CSS file. In my case I had emmet enabled, but while I could get emmet abbreviation in a CSS file, they wouldn't work in an HTML file. The issue was that I also had Django template extension installed and the file had Django template code as well, hence VScode considered the file as Django template file, not HTML. You can check this the status bar at the bottom of VScode. Once I changed the file from Django template to HTML by clicking on Django Template in the VScode status bar, emmet started working.
The above answers didn't help me because VS code already came with Emmet installed, but I was missing the information on how to actually trigger it.
For an html element
Type the element e.g. div, h1, whatever, then press tab to complete it
For a class
Type the class name beginning with a dot then press tab to complete it.
For example type .myclass and hit tab and you'll get <div class="myclass"></div>
Note: if your class has spaces, use a dot in place of the space (e.g. for "my great class", you should type ".my.great.class" and hit tab)
Source
This information is from here
Tried mentioned thing from emmet vs code document
go-to .vscode >> settings.json
add line "emmet.triggerExpansionOnTab": true
it worked for me for reference : Emmet in visual studio code

libraries-override not working on Drupal 8

I'm trying to figure out how I can remove the default css libraries of Drupal 8 on the theme I'm working on. I tried using libraries-override: to remove a specific CSS but it doesn't seem to be working. The css file is still showing. As you can see the align.module.css is still showing on Google Network Tab. I'm not sure if the method I'm using is deprecated or incorrect
name: Barebones
description: Drupal light
type: theme
core: 8.x
base theme: stable
libraries-override:
system/base:
css:
component:
/core/modules/system/css/components/align.module.css: false
Maybe help(not tested)
libraries-remove
The ability to remove entire libraries.
libraries-remove:
subtheme/library
core/modernizr
libraries-override
The ability to override entire libraries and parts of libraries:
libraries-override:
# Replace an entire library.
core/drupal.collapse: mytheme/collapse
# Replace an asset with another.
subtheme/library:
css:
theme:
css/layout.css: css/my-layout.css
# Remove an asset.
drupal/dialog:
css:
theme:
dialog.theme.css: false
# Remove an entire library.
core/modernizr: false

Resources