How can I incorporate a CSS class into a Markdown file?
For example, using
<i class="icon-renren"></i>
(from the fontawesome
library) should display an icon when its CSS file is imported in HTML.
Is there a way to achieve this in Markdown?
How can I incorporate a CSS class into a Markdown file?
For example, using
<i class="icon-renren"></i>
(from the fontawesome
library) should display an icon when its CSS file is imported in HTML.
Is there a way to achieve this in Markdown?
Feel free to incorporate HTML within your markdown just like you would with regular text.
<style>
highlight{
background-color:yellow;
}
</style>
<highlight>The Definition of Database</highlight>
If you’re looking to enhance the styling of your documents, consider using Pandoc attributes syntax. This tool can easily convert Markdown to various formats such as HTML, PDF, and PowerPoint presentations.
Creating heading identifiers:
### Add a red text title {#identifier .red}
Including code blocks with attributes:
{.red .numberLines startFrom="1"}
Customizing inline code snippets:
`This text will appear in red`{.red}
Applying styles to specific spans of text:
[Highlight this phrase within brackets]{.red}
Adjusting attributes for links:
![Displaying an image with altered alignment](the.jpg){.center}
Update: Including FontAwesome icons in R Markdown (or Shiny Apps) can now be easily accomplished with a new package available here: https://github.com/rstudio/fontawesome. While the following solution is more versatile and not specifically for R Markdown or FontAwesome, it still provides a workaround.
Although not tested in Gitbook
, I'm optimistic that this method will work seamlessly on github
.
Here's an approach for incorporating Font Awesome icons in an html
document written in markdown
(using knitr
). To ensure proper display on github
, I've utilized a workaround by linking to htmlpreview.github.io/?
(as mentioned by niutech here):
.Rmd
file.font-awesome-4.4.0/css/font-awesome.css
to the header of your .Rmd
file to specify which .css
file markdown should use. Note that changing the version number may be necessary.Ensure that you set self_contained: no
. As jmcphers pointed out here, this option prevents pandoc
from merging multiple files into one, which could affect the paths in the font-awesome.css
file.
In your .Rmd
document, add a link to
http://htmlpreview.github.io/?/url_to_html_on_github
replacing url_to_html_on_github
with the URL to your html file on github.Below is a simple example (fa-5x
enlarges the icon, as illustrated in these examples):
---
title: "Title"
author: "Author"
date: "DATE"
output:
html_document:
css: font-awesome-4.4.0/css/font-awesome.css
self_contained: no
---
<i class="fa fa-renren fa-5x"></i>
To view the rendered html file correctly, click
<a href="http://htmlpreview.github.io/?https://github.com/FlorianWanders/FAonGitHub/blob/master/MWE.html" title="preview on htmlpreview.github.io" target="_blank">here</a>.
Check out the preview of the result (also available in this github repository):
First and foremost, the majority of markdown implementations support the use of basic html
Some markdown implementations also allow for additional syntax to include attributes such as ids and classes (for example, php-markdown uses {#id .class}
for block elements)
To my knowledge, fontawesome always requires the use of the leading <i>
tag. Other icon fonts (like weloveiconfonts) insert the icon into an existing html tag like
<h2 class="zocial-dribbble">text</h2>
, in markdown-extra: ## text {.zocial-dribbble}
.
Encountering an issue with the TwitterBootstrap CSS menu on this page when viewed on a smartphone: The div containing the menu does not resize its height, causing it to invade the content below when the "Menu" is clicked. I've been unable to find a ...
I successfully set up jQuery niceScroll on the body, but now I want different themed scrollbars on one page. Below is my code snippet: Here is my fiddle: http://jsfiddle.net/JPA4R/135/ <script> $(document).ready(function () { $("body").niceScroll ...
Here is the code snippet: <div id="root"> <div id="child1">xxxx</div> <div id="child2">yyyy</div> </div> CSS : #root{ width: 86%; margin: 0 auto; } #root div { width: 50%; float: left; border: ...
Here is the HTML code snippet I am working with: <div class="section"> <div class="header">header</div> <div class="content"> <div>sub contents 1</div> <di ...
There seems to be an issue with the four links in the third column, first, second, third, and fourth rows (Order Form PDF, Rental App PDF, Married Rental PDF, and Consent Form PDF) as they are not functioning properly. Below is the provided code snippet: ...
Currently, I am using bootstrap's has-error and help-block classes to display validation error messages in my form. However, I find the error message display in Stackoverflow's Ask Questions Form to be very appealing. Are they using a specific js ...
The image on the screen is not resizing properly. Please refer to the image with the alternate text google-play-badge. Even though the width and height of the image are set to auto, it is still not adjusting automatically. Here are my codes: body { ...
Here is the code I am working with: <html> <head> <style> body { margin: auto; width: 720px; } </style> </head> <body> <p>Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ip ...
I'm looking to update the text displayed inside a button when hovering over it, similar to the examples in these images. I have already implemented the active state, but now I just need to change the text content. <button type="submit" ...
For those with more programming experience than myself, I have a simple question. In Rails, using coffescript, I want to show additional content based on a user's selection. Essentially, if they click on a checkbox, it should reveal an extra field for ...
I am struggling to replace a background image in CSS with an icon font instead of an icon image. I have been unable to accomplish this task. Here is the CSS property I am working with: .social-networks .twitter{background:url(../images/social/twitter.png) ...
Why is it difficult to obtain the width of hidden elements? Here is my code: .hidden { display: none; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> <ul class="navbar-items"> <li> ...
For my project, I have a requirement to use custom svg files. To achieve this, I am utilizing <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0865697c6d7a616964257d61483b2631263b">[email protected]</a>. I reviewed ...
I'm struggling to change the background color of the property address picker dropdown from transparent to white. I've been trying different things but can't seem to get it right. Any suggestions? Additionally, I want to change the cursor to ...
I have been tasked with embedding a relatively small PDF file within an HTML page and printing the entire page, including the PDF file inside an iframe. Below is the structure of my HTML page: https://i.stack.imgur.com/1kJZn.png Here is the code I am usin ...
One of my goals is to ensure that when the viewport is taller than the content, the content is vertically centered. However, if the viewport is not tall enough and the content overflows, I want the parent element to provide a vertical scrollbar. How can I ...
Typically, modern web browsers will automatically merge certain letter combinations, such as 'f' and 'i', into a single character known as a ligature. While this can enhance readability, it may not always align with a designer's pr ...
In the given code, I am trying to create a function where if no photo is uploaded, a default bootstrap glyphicon-user image should be displayed. Once a photo is uploaded, it should overwrite the default image. //Please ensure necessary Bootstrap files are ...
After extensively researching, I have come across numerous articles advocating for the use of transform and opacity for achieving smooth CSS transitions. An example can be found here: The prevailing notion always revolves around: ...the optimization ...
Trying to use flexbox to display data from a dataset in my code. Here is the code snippet: <div ng-app="myapp" ng-controller="FirstCtrl"> <div ng-repeat="name in names" class="graph-wrapper"> <div class="aside-1 content"> ...