Kaycee  Olson

Kaycee Olson

1624259640

How to Get Post and Page IDs in WordPress

On the hunt for a specific page or post’s ID? 🔍 Look no further. This guide has 5 easy ways to find them!

There are a lot of situations when you might need to know what a specific page or post’s ID is in WordPress. A plugin might need it to exclude that page from a feature, for example. Alternatively, if you’re a developer, you could have to query that ID.

Page and post ID numbers are how WordPress identifies each piece of content on your website. Traditionally, the platform doesn’t display that information openly, but it’s easy enough to find if you know where to look for it.

In this tutorial, we’ll show you five different ways to get post IDs in WordPress, ranging from the traditional to the unorthodox.

🕘Timestamps

  • 0:00 How to Get Post and Page IDs in WordPress
  • 0:43 Why It’s Useful to Know How to Identify WordPress Post and Page IDs
  • 1:25 5 Steps to Get Post IDs in WordPress
  • 1:31 Find The ID Within Each Post’s URL
  • 2:32 Use Custom Code to Display Post IDs in The Posts Tab
  • 3:49 Use a Plugin to Display Post IDs in WordPress
  • 4:27 Find Post IDs Within the WordPress Database
  • 5:08 Use Functions to Fetch WordPress Post IDs

#wordpress

What is GEEK

Buddha Community

How to Get Post and Page IDs in WordPress
Shubham Ankit

Shubham Ankit

1657081614

How to Automate Excel with Python | Python Excel Tutorial (OpenPyXL)

How to Automate Excel with Python

In this article, We will show how we can use python to automate Excel . A useful Python library is Openpyxl which we will learn to do Excel Automation

What is OPENPYXL

Openpyxl is a Python library that is used to read from an Excel file or write to an Excel file. Data scientists use Openpyxl for data analysis, data copying, data mining, drawing charts, styling sheets, adding formulas, and more.

Workbook: A spreadsheet is represented as a workbook in openpyxl. A workbook consists of one or more sheets.

Sheet: A sheet is a single page composed of cells for organizing data.

Cell: The intersection of a row and a column is called a cell. Usually represented by A1, B5, etc.

Row: A row is a horizontal line represented by a number (1,2, etc.).

Column: A column is a vertical line represented by a capital letter (A, B, etc.).

Openpyxl can be installed using the pip command and it is recommended to install it in a virtual environment.

pip install openpyxl

CREATE A NEW WORKBOOK

We start by creating a new spreadsheet, which is called a workbook in Openpyxl. We import the workbook module from Openpyxl and use the function Workbook() which creates a new workbook.

from openpyxl
import Workbook
#creates a new workbook
wb = Workbook()
#Gets the first active worksheet
ws = wb.active
#creating new worksheets by using the create_sheet method

ws1 = wb.create_sheet("sheet1", 0) #inserts at first position
ws2 = wb.create_sheet("sheet2") #inserts at last position
ws3 = wb.create_sheet("sheet3", -1) #inserts at penultimate position

#Renaming the sheet
ws.title = "Example"

#save the workbook
wb.save(filename = "example.xlsx")

READING DATA FROM WORKBOOK

We load the file using the function load_Workbook() which takes the filename as an argument. The file must be saved in the same working directory.

#loading a workbook
wb = openpyxl.load_workbook("example.xlsx")

 

GETTING SHEETS FROM THE LOADED WORKBOOK

 

#getting sheet names
wb.sheetnames
result = ['sheet1', 'Sheet', 'sheet3', 'sheet2']

#getting a particular sheet
sheet1 = wb["sheet2"]

#getting sheet title
sheet1.title
result = 'sheet2'

#Getting the active sheet
sheetactive = wb.active
result = 'sheet1'

 

ACCESSING CELLS AND CELL VALUES

 

#get a cell from the sheet
sheet1["A1"] <
  Cell 'Sheet1'.A1 >

  #get the cell value
ws["A1"].value 'Segment'

#accessing cell using row and column and assigning a value
d = ws.cell(row = 4, column = 2, value = 10)
d.value
10

 

ITERATING THROUGH ROWS AND COLUMNS

 

#looping through each row and column
for x in range(1, 5):
  for y in range(1, 5):
  print(x, y, ws.cell(row = x, column = y)
    .value)

#getting the highest row number
ws.max_row
701

#getting the highest column number
ws.max_column
19

There are two functions for iterating through rows and columns.

Iter_rows() => returns the rows
Iter_cols() => returns the columns {
  min_row = 4, max_row = 5, min_col = 2, max_col = 5
} => This can be used to set the boundaries
for any iteration.

Example:

#iterating rows
for row in ws.iter_rows(min_row = 2, max_col = 3, max_row = 3):
  for cell in row:
  print(cell) <
  Cell 'Sheet1'.A2 >
  <
  Cell 'Sheet1'.B2 >
  <
  Cell 'Sheet1'.C2 >
  <
  Cell 'Sheet1'.A3 >
  <
  Cell 'Sheet1'.B3 >
  <
  Cell 'Sheet1'.C3 >

  #iterating columns
for col in ws.iter_cols(min_row = 2, max_col = 3, max_row = 3):
  for cell in col:
  print(cell) <
  Cell 'Sheet1'.A2 >
  <
  Cell 'Sheet1'.A3 >
  <
  Cell 'Sheet1'.B2 >
  <
  Cell 'Sheet1'.B3 >
  <
  Cell 'Sheet1'.C2 >
  <
  Cell 'Sheet1'.C3 >

To get all the rows of the worksheet we use the method worksheet.rows and to get all the columns of the worksheet we use the method worksheet.columns. Similarly, to iterate only through the values we use the method worksheet.values.


Example:

for row in ws.values:
  for value in row:
  print(value)

 

WRITING DATA TO AN EXCEL FILE

Writing to a workbook can be done in many ways such as adding a formula, adding charts, images, updating cell values, inserting rows and columns, etc… We will discuss each of these with an example.

 

CREATING AND SAVING A NEW WORKBOOK

 

#creates a new workbook
wb = openpyxl.Workbook()

#saving the workbook
wb.save("new.xlsx")

 

ADDING AND REMOVING SHEETS

 

#creating a new sheet
ws1 = wb.create_sheet(title = "sheet 2")

#creating a new sheet at index 0
ws2 = wb.create_sheet(index = 0, title = "sheet 0")

#checking the sheet names
wb.sheetnames['sheet 0', 'Sheet', 'sheet 2']

#deleting a sheet
del wb['sheet 0']

#checking sheetnames
wb.sheetnames['Sheet', 'sheet 2']

 

ADDING CELL VALUES

 

#checking the sheet value
ws['B2'].value
null

#adding value to cell
ws['B2'] = 367

#checking value
ws['B2'].value
367

 

ADDING FORMULAS

 

We often require formulas to be included in our Excel datasheet. We can easily add formulas using the Openpyxl module just like you add values to a cell.
 

For example:

import openpyxl
from openpyxl
import Workbook

wb = openpyxl.load_workbook("new1.xlsx")
ws = wb['Sheet']

ws['A9'] = '=SUM(A2:A8)'

wb.save("new2.xlsx")

The above program will add the formula (=SUM(A2:A8)) in cell A9. The result will be as below.

image

 

MERGE/UNMERGE CELLS

Two or more cells can be merged to a rectangular area using the method merge_cells(), and similarly, they can be unmerged using the method unmerge_cells().

For example:
Merge cells

#merge cells B2 to C9
ws.merge_cells('B2:C9')
ws['B2'] = "Merged cells"

Adding the above code to the previous example will merge cells as below.

image

UNMERGE CELLS

 

#unmerge cells B2 to C9
ws.unmerge_cells('B2:C9')

The above code will unmerge cells from B2 to C9.

INSERTING AN IMAGE

To insert an image we import the image function from the module openpyxl.drawing.image. We then load our image and add it to the cell as shown in the below example.

Example:

import openpyxl
from openpyxl
import Workbook
from openpyxl.drawing.image
import Image

wb = openpyxl.load_workbook("new1.xlsx")
ws = wb['Sheet']
#loading the image(should be in same folder)
img = Image('logo.png')
ws['A1'] = "Adding image"
#adjusting size
img.height = 130
img.width = 200
#adding img to cell A3

ws.add_image(img, 'A3')

wb.save("new2.xlsx")

Result:

image

CREATING CHARTS

Charts are essential to show a visualization of data. We can create charts from Excel data using the Openpyxl module chart. Different forms of charts such as line charts, bar charts, 3D line charts, etc., can be created. We need to create a reference that contains the data to be used for the chart, which is nothing but a selection of cells (rows and columns). I am using sample data to create a 3D bar chart in the below example:

Example

import openpyxl
from openpyxl
import Workbook
from openpyxl.chart
import BarChart3D, Reference, series

wb = openpyxl.load_workbook("example.xlsx")
ws = wb.active

values = Reference(ws, min_col = 3, min_row = 2, max_col = 3, max_row = 40)
chart = BarChart3D()
chart.add_data(values)
ws.add_chart(chart, "E3")
wb.save("MyChart.xlsx")

Result
image


How to Automate Excel with Python with Video Tutorial

Welcome to another video! In this video, We will cover how we can use python to automate Excel. I'll be going over everything from creating workbooks to accessing individual cells and stylizing cells. There is a ton of things that you can do with Excel but I'll just be covering the core/base things in OpenPyXl.

⭐️ Timestamps ⭐️
00:00 | Introduction
02:14 | Installing openpyxl
03:19 | Testing Installation
04:25 | Loading an Existing Workbook
06:46 | Accessing Worksheets
07:37 | Accessing Cell Values
08:58 | Saving Workbooks
09:52 | Creating, Listing and Changing Sheets
11:50 | Creating a New Workbook
12:39 | Adding/Appending Rows
14:26 | Accessing Multiple Cells
20:46 | Merging Cells
22:27 | Inserting and Deleting Rows
23:35 | Inserting and Deleting Columns
24:48 | Copying and Moving Cells
26:06 | Practical Example, Formulas & Cell Styling

📄 Resources 📄
OpenPyXL Docs: https://openpyxl.readthedocs.io/en/stable/ 
Code Written in This Tutorial: https://github.com/techwithtim/ExcelPythonTutorial 
Subscribe: https://www.youtube.com/c/TechWithTim/featured 

#python 

Bongani  Ngema

Bongani Ngema

1670346000

How to Create & Add Content - Images, Text To Modern SharePoint Pages

Description

Requirement is to create Modern pages with content, which includes images and text. 

The Content is in SharePoint List. The pages are created from a Page Template.

To get Text part from Page template, use below PowerShell,

#get page textpart instance id
$parts=Get-PnPPageComponent -Page <pagename.aspx>

Execute the below PowerShell to create pages with HTML content from SharePoint List.

$logFile = "Logs\LogFile.log"
Start - Transcript - Path $logFile - Append
#Variables
$libName = "Site Pages"
$siteURL = "https://tenant.sharepoint.com/"
$contentType = "Group and Division Page"
$listname = "Content"
$sectionCategoy = "Our organisation"
#End
Try {
    #Connect to PnP Online
    $connection = Connect - PnPOnline - Url $siteURL - UseWebLogin - ReturnConnection - WarningAction Ignore
    #Get items from Content list
    $items = Get - PnPListItem - List $listName - PageSize 100
    foreach($item in $items) {
        if ($null - ne $item["Title"] - and $null - ne $item["Content"]) {
            #Get Page webparts instance Id
            #$parts = Get - PnPPageComponent - Page PageTemplate.aspx
            # load the page template
            $template = Get - PnPClientSidePage - Identity "Templates/Division-page-template"
            #Get page name
            $fullFileName = $item["Title"].Replace(" ", "_") + ".aspx"
            #Create fileURL
            $fileURL = $siteURL + $libName + "/" + $fullFileName
            # save a new SharePoint Page based on the Page Template
            $template.Save($fullFileName)
            $page = Get - PnPPage - Identity $fullFileName
            $htmlToInject = $item["Content"]
            $htmlToInject = $htmlToInject.TrimStart('{"Html":"').TrimEnd('"}') - replace([regex]::Escape('\n')), '' - replace([regex]::Escape('<a href=\')),' < a href = ' -replace ([regex]:: Escape('\
                        ">')),'" > ' -replace ([regex]::Escape(' & bull; % 09 ')),'
                        ' -replace '
                        https:
                        /*','https://'
            #Set PnP Page Text

            Set-PnPPageTextPart -Page $page -InstanceId "9fab3ce6-0638-4008-a9b9-cf2b784245b5" -Text $htmlToInject


            #publish page
            Set-PnPPage -Identity $fullFileName -Title $item["Title"] -ContentType $contentType -Publish

            #get site pages library
            $sitepagelist= Get-PnPList -Identity 'Site Pages'
            #get page Id and page Item to update section category
            $pageItem=Get-PnPListItem -List $sitepagelist -Id $page.PageId
            Set-PnPListItem -Values @{"SectionCategory" = $sectionCategoy} -List $sitepagelist -Identity $pageItem

        }
        else
        {
            Write-Host "Title or Content has no value"
        }
    }
}
Catch {
    Write-Host "Error: $($_.Exception.Message)" -Foregroundcolor Red
}
Stop-Transcript

Original article source at: https://www.c-sharpcorner.com/

#sharepoint #image #text 

Top 7 Post Timeline WordPress Plugins

Want to feature a brand history or storyline on a WordPress website? If yes, then read this blog thoroughly.

Many of your website visitors want to know about your brand history or the achievements of your past. For that, a timeline layout is a good solution. Showcase the story of your company or brand in chronological order with the dazzling post timeline posts. WordPress has several themes that have default horizontal timeline formats. But, to get a fully functional & beautifully designed timeline WordPress has plenty of resources of timeline plugins.

No concerns! We have assembled the best post timeline WordPress plugins. Each set of plugins have different functionalities and customization settings. Get the best one and create a timeline with the best one!

1. WP Timeline Designer Pro

WP Timeline Designer is a feature-rich plugin that provides vertical and horizontal timeline templates with lots of advanced functionalities. While showcasing a story or company history with the beautiful chart or design then timeline layout helps to easily understand and attract the readers as well. A great way to tell a story or create a post then the timeline plugin helps to create an attractive timeline.

Timeline Designer – Free

Timeline Designer – a free plugin recently launched on the WordPress repository platform. The free plugin contains in-built 6 existing customizable layouts with other customization options. Using this WordPress plugin, a user can match the look & feel of your WordPress site.
This is image title

Features:

  • Supports custom post type.
  • Provides the customization of background color, show/hide timeline icon, template layout color, and basic animations.
  • Style the post with the stunning content box.
  • With the Horizontal timeline layout, a user gets the navigation option such as auto slide, number of slides, scrolling speed, etc.
  • The plugin has Shortcode functionality with which a user can showcase timeline posts anywhere on the website.

WP Timeline Designer Pro – Premium

WP Timeline Designer Pro is an elegant and fantastic plugin with responsive timeline layouts. In the pro version, the plugin contains 15+ timeline templates with lots of options and tools to style and design the posts. It has in-built 20+ core demos available with which a user can showcase life story, event summary, author biography, achievements, company history, hiring process, etc in an eye-catchy timeline design.
This is image title

Features:

  • 12+ post animation effects on scrolling.
  • Advanced filter post with the date, time period, author, post category, post status, etc.
  • 10+ social sharing icons available and available in the library to change the icon settings anytime.
  • The plugin allows you to add different types of pagination options such as load more buttons, pagination on scroll, etc.
  • The premium plugin contains several media options for timeline posts such as hover effect on images, adjust image size, or text. link on media, custom image size, etc.

2. Post Timeline

Post Timeline plugin allows creating a timeline on 100% of the page. It allows the creation of unlimited vertical and horizontal timelines. To create a simple and single timeline, a user can use shortcode functionality.

**Post Timeline – Free **

The Post Timeline Free plugin allows you to create a timeline on the vertical layout. A user can also assign the category and tags.

Features:

  • Smooth Animation & Slide Navigation is available.
  • The plugin helps to create a tag-based and year-based timeline with parameters.
  • The free plugin has customization offers such as color, assign different icons, etc.
    This is image title

Post Timeline – Premium

The pro version of the Post Timeline WordPress plugin has both vertical and horizontal timeline layouts. The plugin has inbuilt 23 timeline templates and all the timelines layout can be chosen by the admin for each timeline.

Features:

  • The plugin has CSS3 animation + JS animation to make the timeline post prettier.
  • Post Timeline comes with the backend template manager. It allows a user to preview the timeline on the page with the required content.
  • 5 navigation options available.

3. Cool Timeline

Cool Timeline, as its name suggests, creates a complete timeline layout for the WordPress website. It is an HTML and CSS timeline plugin that helps to build awesome horizontal and vertical layouts. The new version of the plugin is very well compatible with Gutenberg.

**Cool Timeline: Free **

The Cool Timeline with the free version has 5 vertical and one horizontal timeline design. Also, the plugin allows users to showcase the stories in ascending & descending orders based on the year and date.

Features:

  • It is a Gutenberg-friendly WordPress plugin with which a user can add shortcodes on any page using the Gutenberg block.
  • A user can showcase the timeline images in the pop-up and link them to read a full story.
  • Using this plugin, you can create a timeline both-sided as well as one-sided.
    This is image title

Cool TimelineCool Timeline: Premium

Cool Timeline Pro plugin has an advanced admin panel that helps to manage the timeline visibility details & other customization factors very smoothly. The premium plugin comes with 4 timeline layouts with 40+ several timeline designs.

Features:

  • It provides a custom text and custom story order in/place of date and time in a timeline layout.
  • Create multiple timelines in one website with the different categories
  • The plugin comes with the proper navigation options, so a user can quickly navigate to a particular story.

#best wordpress timeline plugin #post timeline plugin wordpress #post timeline wordpress #timeline plugin for wordpress #wordpress post timeline plugins #wordpress timeline plugin

Top 7 Post Timeline WordPress Plugins

Want to feature a brand history or storyline on a WordPress website? If yes, then read this blog thoroughly.

Many of your website visitors want to know about your brand history or the achievements of your past. For that, a timeline layout is a good solution. Showcase the story of your company or brand in chronological order with the dazzling post timeline posts. WordPress has several themes that have default horizontal timeline formats. But, to get a fully functional & beautifully designed timeline WordPress has plenty of resources of timeline plugins.

No concerns! We have assembled the best post timeline WordPress plugins. Each set of plugins have different functionalities and customization settings. Get the best one and create a timeline with the best one!

1. WP Timeline Designer Pro

WP Timeline Designer is a feature-rich plugin that provides vertical and horizontal timeline templates with lots of advanced functionalities. While showcasing a story or company history with the beautiful chart or design then timeline layout helps to easily understand and attract the readers as well. A great way to tell a story or create a post then the timeline plugin helps to create an attractive timeline.

Timeline Designer – Free

Timeline Designer – a free plugin recently launched on the WordPress repository platform. The free plugin contains in-built 6 existing customizable layouts with other customization options. Using this WordPress plugin, a user can match the look & feel of your WordPress site.

Features:

  • Supports custom post type.
  • Provides the customization of background color, show/hide timeline icon, template layout color, and basic animations.
  • Style the post with the stunning content box.
  • With the Horizontal timeline layout, a user gets the navigation option such as auto slide, number of slides, scrolling speed, etc.
  • The plugin has Shortcode functionality with which a user can showcase timeline posts anywhere on the website.

WP Timeline Designer Pro – Premium

WP Timeline Designer Pro is an elegant and fantastic plugin with responsive timeline layouts. In the pro version, the plugin contains 15+ timeline templates with lots of options and tools to style and design the posts. It has in-built 20+ core demos available with which a user can showcase life story, event summary, author biography, achievements, company history, hiring process, etc in an eye-catchy timeline design.

Features:

  • 12+ post animation effects on scrolling.
  • Advanced filter post with the date, time period, author, post category, post status, etc.
  • 10+ social sharing icons available and available in the library to change the icon settings anytime.
  • The plugin allows you to add different types of pagination options such as load more buttons, pagination on scroll, etc.
  • The premium plugin contains several media options for timeline posts such as hover effect on images, adjust image size, or text. link on media, custom image size, etc.

2. Post Timeline

Post Timeline plugin allows creating a timeline on 100% of the page. It allows the creation of unlimited vertical and horizontal timelines. To create a simple and single timeline, a user can use shortcode functionality.

**Post Timeline – Free **

The Post Timeline Free plugin allows you to create a timeline on the vertical layout. A user can also assign the category and tags.

Features:

  • Smooth Animation & Slide Navigation is available.
  • The plugin helps to create a tag-based and year-based timeline with parameters.
  • The free plugin has customization offers such as color, assign different icons, etc.

Post Timeline – Premium

The pro version of the Post Timeline WordPress plugin has both vertical and horizontal timeline layouts. The plugin has inbuilt 23 timeline templates and all the timelines layout can be chosen by the admin for each timeline.

Features:

  • The plugin has CSS3 animation + JS animation to make the timeline post prettier.
  • Post Timeline comes with the backend template manager. It allows a user to preview the timeline on the page with the required content.
  • 5 navigation options available.

3. Cool Timeline

Cool Timeline, as its name suggests, creates a complete timeline layout for the WordPress website. It is an HTML and CSS timeline plugin that helps to build awesome horizontal and vertical layouts. The new version of the plugin is very well compatible with Gutenberg.

**Cool Timeline: Free **

The Cool Timeline with the free version has 5 vertical and one horizontal timeline design. Also, the plugin allows users to showcase the stories in ascending & descending orders based on the year and date.

Features:

  • It is a Gutenberg-friendly WordPress plugin with which a user can add shortcodes on any page using the Gutenberg block.
  • A user can showcase the timeline images in the pop-up and link them to read a full story.
  • Using this plugin, you can create a timeline both-sided as well as one-sided.

Cool TimelineCool Timeline: Premium

Cool Timeline Pro plugin has an advanced admin panel that helps to manage the timeline visibility details & other customization factors very smoothly. The premium plugin comes with 4 timeline layouts with 40+ several timeline designs.

Features:

  • It provides a custom text and custom story order in/place of date and time in a timeline layout.
  • Create multiple timelines in one website with the different categories
  • The plugin comes with the proper navigation options, so a user can quickly navigate to a particular story.

#best wordpress timeline plugin #post timeline plugin wordpress #post timeline wordpress #timeline plugin for wordpress #wordpress post timeline plugins #wordpress timeline plugin

Gordon  Matlala

Gordon Matlala

1667279100

Jekyll-spaceship: Jekyll Plugin for Astronauts

 🚀 Jekyll Spaceship 🚀 

Jekyll plugin for Astronauts.

Spaceship is a minimalistic, powerful and extremely customizable Jekyll plugin. It combines everything you may need for convenient work, without unnecessary complications, like a real spaceship.

Jekyll Spaceship Demo

💡 Tip: I hope you enjoy using this plugin. If you like this project, a little star for it is your way make a clear statement: My work is valued. I would appreciate your support! Thank you!

Requirements

  • Ruby >= 2.3.0

Installation

Add jekyll-spaceship plugin in your site's Gemfile, and run bundle install.

# If you have any plugins, put them here!
group :jekyll_plugins do
  gem 'jekyll-spaceship'
end

Or you better like to write in one line:

gem 'jekyll-spaceship', group: :jekyll_plugins

Add jekyll-spaceship to the plugins: section in your site's _config.yml.

plugins:
  - jekyll-spaceship

💡 Tip: Note that GitHub Pages runs in safe mode and only allows a set of whitelisted plugins. To use the gem in GitHub Pages, you need to build locally or use CI (e.g. travis, github workflow) and deploy to your gh-pages branch.

Additions for Unlimited GitHub Pages

  • Here is a GitHub Action named jekyll-deploy-action for Jekyll site deployment conveniently. 👍
  • Here is a Jekyll site using Travis to build and deploy to GitHub Pages for your references.

Configuration

This plugin runs with the following configuration options by default. Alternative settings for these options can be explicitly specified in the configuration file _config.yml.

# Where things are
jekyll-spaceship:
  # default enabled processors
  processors:
    - table-processor
    - mathjax-processor
    - plantuml-processor
    - mermaid-processor
    - polyfill-processor
    - media-processor
    - emoji-processor
    - element-processor
  mathjax-processor:
    src:
      - https://polyfill.io/v3/polyfill.min.js?features=es6
      - https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
    config:
      tex:
        inlineMath:
          - ['$','$']
          - ['\(','\)']
        displayMath:
          - ['$$','$$']
          - ['\[','\]']
      svg:
        fontCache: 'global'
    optimize: # optimization on building stage to check and add mathjax scripts
      enabled: true # value `false` for adding to all pages
      include: []   # include patterns for math expressions checking (regexp)
      exclude: []   # exclude patterns for math expressions checking (regexp)
  plantuml-processor:
    mode: default  # mode value 'pre-fetch' for fetching image at building stage
    css:
      class: plantuml
    syntax:
      code: 'plantuml!'
      custom: ['@startuml', '@enduml']
    src: http://www.plantuml.com/plantuml/svg/
  mermaid-processor:
    mode: default  # mode value 'pre-fetch' for fetching image at building stage
    css:
      class: mermaid
    syntax:
      code: 'mermaid!'
      custom: ['@startmermaid', '@endmermaid']
    config:
      theme: default
    src: https://mermaid.ink/svg/
  media-processor:
    default:
      id: 'media-{id}'
      class: 'media'
      width: '100%'
      height: 350
      frameborder: 0
      style: 'max-width: 600px; outline: none;'
      allow: 'encrypted-media; picture-in-picture'
  emoji-processor:
    css:
      class: emoji
    src: https://github.githubassets.com/images/icons/emoji/

Usage

1. Table Usage

For now, these extended features are provided:

  • Cells spanning multiple columns
  • Cells spanning multiple rows
  • Cells text align separately
  • Table header not required
  • Grouped table header rows or data rows

Noted that GitHub filters out style property, so the example displays with the obsolete align property. But in actual this plugin outputs style property with text-align CSS attribute.

Rowspan and Colspan

^^ in a cell indicates it should be merged with the cell above.
This feature is contributed by pmccloghrylaing.

|              Stage | Direct Products | ATP Yields |
| -----------------: | --------------: | ---------: |
|         Glycolysis |          2 ATP              ||
| ^^                 |          2 NADH |   3--5 ATP |
| Pyruvaye oxidation |          2 NADH |      5 ATP |
|  Citric acid cycle |          2 ATP              ||
| ^^                 |          6 NADH |     15 ATP |
| ^^                 |          2 FADH |      3 ATP |
|                               30--32 ATP        |||

Code above would be parsed as:

StageDirect ProductsATP Yields
Glycolysis2 ATP
2 NADH3–5 ATP
Pyruvaye oxidation2 NADH5 ATP
Citric acid cycle2 ATP
6 NADH15 ATP
2 FADH23 ATP
30–32 ATP

Multiline

A backslash at end to join cell contents with the following lines.
This feature is contributed by Lucas-C.

| :    Easy Multiline   : |||
| :----- | :----- | :------ |
| Apple  | Banana | Orange  \
| Apple  | Banana | Orange  \
| Apple  | Banana | Orange
| Apple  | Banana | Orange  \
| Apple  | Banana | Orange  |
| Apple  | Banana | Orange  |

Code above would be parsed as:

Easy Multiline
Apple
Apple
Apple
Banana
Banana
Banana
Orange
Orange
Orange
Apple
Apple
Banana
Banana
Orange
Orange
AppleBananaOrange

Headerless

Table header can be eliminated.

|--|--|--|--|--|--|--|--|
|♜| |♝|♛|♚|♝|♞|♜|
| |♟|♟|♟| |♟|♟|♟|
|♟| |♞| | | | | |
| |♗| | |♟| | | |
| | | | |♙| | | |
| | | | | |♘| | |
|♙|♙|♙|♙| |♙|♙|♙|
|♖|♘|♗|♕|♔| | |♖|

Code above would be parsed as:

 
  
      
      
       
       
 
  

Cell Alignment

Markdown table syntax use colons ":" for forcing column alignment.
Therefore, here we also use it for forcing cell alignment.

Table cell can be set alignment separately.

| :        Fruits \|\| Food       : |||
| :--------- | :-------- | :--------  |
| Apple      | : Apple : | Apple      \
| Banana     |   Banana  | Banana     \
| Orange     |   Orange  | Orange     |
| :   Rowspan is 4    : || How's it?  |
|^^    A. Peach         ||   1. Fine :|
|^^    B. Orange        ||^^ 2. Bad   |
|^^    C. Banana        ||  It's OK!  |

Code above would be parsed as:

Fruits || Food
Apple
Banana
Orange
Apple
Banana
Orange
Apple
Banana
Orange
Rowspan is 4 
A. Peach 
B. Orange 
C. Banana
 
How's it?
1. Fine
2. Bad
It' OK!

Cell Markdown

Sometimes we may need some abundant content (e.g., mathjax, image, video) in Markdown table
Therefore, here we also make markown syntax possible inside a cell.

| :                   MathJax \|\| Image                 : |||
| :------------ | :-------- | :----------------------------- |
| Apple         | : Apple : | Apple                          \
| Banana        | Banana    | Banana                         \
| Orange        | Orange    | Orange                         |
| :     Rowspan is 4     : || :        How's it?           : |
| ^^     A. Peach          ||    1. ![example][cell-image]   |
| ^^     B. Orange         || ^^ 2. $I = \int \rho R^{2} dV$ |
| ^^     C. Banana         || **It's OK!**                   |

[cell-image]: https://jekyllrb.com/img/octojekyll.png "An exemplary image"

Code above would be parsed as:

MathJax || Image
Apple
Banana
Orange
Apple
Banana
Orange
Apple
Banana
Orange
Rowspan is 4 
A. Peach 
B. Orange 
C. Banana
 
How's it?
It' OK!

 

Cell Inline Attributes

This feature is very useful for custom cell such as using inline style. (e.g., background, color, font)
The idea and syntax comes from the Maruku package.

 

Following are some examples of attributes definitions (ALDs) and afterwards comes the syntax explanation:

{:ref-name: #id .cls1 .cls2}
{:second: ref-name #id-of-other title="hallo you"}
{:other: ref-name second}

An ALD line has the following structure:

  • a left brace, optionally preceded by up to three spaces,
  • followed by a colon, the id and another colon,
  • followed by attribute definitions (allowed characters are backslash-escaped closing braces or any character except a not escaped closing brace),
  • followed by a closing brace and optional spaces until the end of the line.

If there is more than one ALD with the same reference name, the attribute definitions of all the ALDs are processed like they are defined in one ALD.

An inline attribute list (IAL) is used to attach attributes to another element.
Here are some examples for span IALs:

{: #id .cls1 .cls2} <!-- #id <=> id="id", .cls1 .cls2 <=> class="cls1 cls2" -->
{: ref-name title="hallo you"}
{: ref-name class='.cls3' .cls4}

Here is an example for custom table cell with IAL:

{:color-style: style="background: black;"}
{:color-style: style="color: white;"}
{:text-style: style="font-weight: 800; text-decoration: underline;"}

|:             Here's an Inline Attribute Lists example                :||||
| ------- | ------------------ | -------------------- | ------------------ |
|:       :|:  <div style="color: red;"> &lt; Normal HTML Block > </div> :|||
| ^^      |   Red    {: .cls style="background: orange" }                |||
| ^^ IALs |   Green  {: #id style="background: green; color: white" }    |||
| ^^      |   Blue   {: style="background: blue; color: white" }         |||
| ^^      |   Black  {: color-style text-style }                         |||

Code above would be parsed as:

IALs

Additionally, here you can learn more details about IALs.

2. MathJax Usage

MathJax is an open-source JavaScript display engine for LaTeX, MathML, and AsciiMath notation that works in all modern browsers.

Some of the main features of MathJax include:

  • High-quality display of LaTeX, MathML, and AsciiMath notation in HTML pages
  • Supported in most browsers with no plug-ins, extra fonts, or special setup for the reader
  • Easy for authors, flexible for publishers, extensible for developers
  • Supports math accessibility, cut-and-paste interoperability, and other advanced functionality
  • Powerful API for integration with other web applications

2.1 Performance optimization

At building stage, the MathJax engine script will be added by automatically checking whether there is a math expression in the page, this feature can help you improve the page performance on loading speed.

2.2 How to use?

Put your math expression within $...$

$ a * b = c ^ b $
$ 2^{\frac{n-1}{3}} $
$ \int\_a^b f(x)\,dx. $

Code above would be parsed as:

MathJax Expression

3. PlantUML Usage

PlantUML is a component that allows to quickly write:

  • sequence diagram,
  • use case diagram,
  • class diagram,
  • activity diagram,
  • component diagram,
  • state diagram,
  • object diagram

There are two ways to create a diagram in your Jekyll blog page:

```plantuml!
Bob -> Alice : hello world
```

or

@startuml
Bob -> Alice : hello
@enduml

Code above would be parsed as:

PlantUML Diagram

4. Mermaid Usage

Mermaid is a Javascript based diagramming and charting tool. It generates diagrams flowcharts and more, using markdown-inspired text for ease and speed.

It allows to quickly write:

  • flow chart,
  • pie chart,
  • sequence diagram,
  • class diagram,
  • state diagram,
  • entity relationship diagram,
  • user journey,
  • gantt

There are two ways to create a diagram in your Jekyll blog page:

```mermaid!
pie title Pets adopted by volunteers
  "Dogs" : 386
  "Cats" : 85
  "Rats" : 35
```

or

@startmermaid
pie title Pets adopted by volunteers
  "Dogs" : 386
  "Cats" : 85
  "Rats" : 35
@endmermaid

Code above would be parsed as:

Mermaid Diagram

5. Media Usage

How often did you find yourself googling "How to embed a video/audio in markdown?"

While its not possible to embed a video/audio in markdown, the best and easiest way is to extract a frame from the video/audio. To add videos/audios to your markdown files easier I developped this tool for you, and it will parse the video/audio link inside the image block automatically.

For now, these media links parsing are provided:

  • Youtube
  • Vimeo
  • DailyMotion
  • Spotify
  • SoundCloud
  • General Video ( mp4 | avi | ogg | ogv | webm | 3gp | flv | mov ... )
  • General Audio ( mp3 | wav | ogg | mid | midi | aac | wma ... )

There are two ways to embed a video/audio in your Jekyll blog page:

Inline-style:

![]({media-link})

Reference-style:

![][{reference}]

[{reference}]: {media-link}

For configuring media attributes (e.g, width, height), just adding query string to the link as below:

![](https://www.youtube.com/watch?v=Ptk_1Dc2iPY?width=800&height=500)

![](https://www.dailymotion.com/video/x7tfyq3?width=100%&height=400&autoplay=1)

Youtube Usage

![](https://www.youtube.com/watch?v=Ptk_1Dc2iPY)

![](//www.youtube.com/watch?v=Ptk_1Dc2iPY?width=800&height=500)

Vimeo Usage

![](https://vimeo.com/263856289)

![](https://vimeo.com/263856289?width=500&height=320)

DailyMotion Usage

![](https://www.dailymotion.com/video/x7tfyq3)

![](https://dai.ly/x7tgcev?width=100%&height=400)

Spotify Usage

![](http://open.spotify.com/track/4Dg5moVCTqxAb7Wr8Dq2T5)

Spotify Podcast Usage

![](https://open.spotify.com/episode/31AxcwYdjsFtStds5JVWbT)

SoundCloud Usage

![](https://soundcloud.com/aviciiofficial/preview-avicii-vs-lenny)

General Video Usage

![](//www.html5rocks.com/en/tutorials/video/basics/devstories.webm)

![](//techslides.com/demos/sample-videos/small.ogv?allow=autoplay)

![](//techslides.com/demos/sample-videos/small.mp4?width=400)

General Audio Usage

![](//www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3)

![](//www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3?autoplay=1&loop=1)

6. Hybrid HTML with Markdown

As markdown is not only a lightweight markup language with plain-text-formatting syntax, but also an easy-to-read and easy-to-write plain text format, so writing a hybrid HTML with markdown is an awesome choice.

It's easy to write markdown inside HTML:

<script type="text/markdown">
# Hybrid HTML with Markdown is a not bad choice ^\_^

## Table Usage

| :        Fruits \|\| Food       : |||
| :--------- | :-------- | :--------  |
| Apple      | : Apple : | Apple      \
| Banana     |   Banana  | Banana     \
| Orange     |   Orange  | Orange     |
| :   Rowspan is 4    : || How's it?  |
|^^    A. Peach         ||   1. Fine :|
|^^    B. Orange        ||^^ 2. Bad   |
|^^    C. Banana        ||  It's OK!  |

## PlantUML Usage

@startuml
Bob -> Alice : hello
@enduml

## Video Usage

![](https://www.youtube.com/watch?v=Ptk_1Dc2iPY)
</script>

7. Markdown Polyfill

It allows us to polyfill features for extending markdown syntax.

For now, these polyfill features are provided:

  • Escape ordered list

7.1 Escape Ordered List

A backslash at begin to escape the ordered list.

Normal:

1. List item Apple.
3. List item Banana.
10. List item Cafe.

Escaped:

\1. List item Apple.
\3. List item Banana.
\10. List item Cafe.

Code above would be parsed as:

Normal:

1. List item Apple.
2. List item Banana.
3. List item Cafe.

Escaped:

1. List item Apple.
3. List item Banana.
10. List item Cafe.

8. Emoji Usage

GitHub-flavored emoji images and names would allow emojifying content such as: it's raining :cat:s and :dog:s!

Noted that emoji images are served from the GitHub.com CDN, with a base URL of https://github.githubassets.com, which results in emoji image URLs like https://github.githubassets.com/images/icons/emoji/unicode/1f604.png.

In any page or post, use emoji as you would normally, e.g.

I give this plugin two :+1:!

Code above would be parsed as:

I give this plugin two :+1:!

8.1 Emoji Customizing

If you'd like to serve emoji images locally, or use a custom emoji source, you can specify so in your _config.yml file:

jekyll-spaceship:
  emoji-processor:
    src: "/assets/images/emoji"

See the Gemoji documentation for generating image files.

9. Modifying Element Usage

It allows us to modify elements via CSS3 selectors. Through it you can easily modify the attributes of an element tag, replace the children nodes and so on, it's very flexible, but here is example usage for modifying a document:

# Here is a comprehensive example
jekyll-spaceship:
  element-processor:
    css:
      - a: '<h1>Test</h1>'                     # Replace all `a` tags (String Style)
      - ['a.link1', 'a.link2']:                # Replace all `a.link1`, `a.link2` tags (Hash Style)
          name: img                            # Replace element tag name
          props:                               # Replace element properties
            title: Good image                  # Add a title attribute
            src: ['(^.*$)', '\0?a=123']        # Add query string to src attribute by regex pattern
            style:                             # Add style attribute (Hash Style)
              color: red
              font-size: '1.2em'
          children:                            # Add children to the element
            -                                  # First empty for adding after the last child node
            - "<span>Google</span>"            # First child node (String Style)
            -                                  # Middle empty for wrapping the children nodes
            - name: span                       # Second child node (Hash Style)
              props:
                prop1: "1"                     # Custom property1
                prop2: "2"                     # Custom property2
                prop3: "3"                     # Custom property3
              children:                        # Add nested chidren nodes
                - "<span>Jekyll</span>"        # First child node (String Style)
                - name: span                   # Second child node (Hash Style)
                  props:                       # Add attributes to child node (Hash Style)
                    prop1: "a"
                    prop2: "b"
                    prop3: "c"
                  children: "<b>Yap!</b>"      # Add children nodes (String Style)
            -                                  # Last empty for adding before the first child node
      - a.link: '<a href="//t.com">Link</a>'   # Replace all `a.link` tags (String Style)
      - 'h1#title':                            # Replace `h1#title` tags (Hash Style)
          children: I'm a title!               # Replace inner html to new text

Example 1

Automatically adds a target="_blank" rel="noopener noreferrer" attribute to all external links in Jekyll's content.

jekyll-spaceship:
  element-processor:
    css:
      - a:                                     # Replace all `a` tags
          props:
            class: ['(^.*$)', '\0 ext-link']   # Add `ext-link` to class by regex pattern
            target: _blank                     # Replace `target` value to `_blank`
            rel: noopener noreferrer           # Replace `rel` value to `noopener noreferrer`

Example 2

Automatically adds loading="lazy" to img and iframe tags to natively load lazily. Browser support is growing. If a browser does not support the loading attribute, it will load the resource just like it would normally.

jekyll-spaceship:
  element-processor:
    css:
      - a:                                     # Replace all `a` tags
          props:                               #
            loading: lazy                      # Replace `loading` value to `lazy`

In case you want to prevent loading some images/iframes lazily, add loading="eager" to their tags. This might be useful to prevent flickering of images during navigation (e.g. the site's logo).

See the following examples to prevent lazy loading.

jekyll-spaceship:
  element-processor:
    css:
      - a:                                     # Replace all `a` tags
          props:                               #
            loading: eager                     # Replace `loading` value to `eager`

There are three options when using this method to lazy load images. Here are the supported values for the loading attribute:

  • auto: Default lazy-loading behavior of the browser, which is the same as not including the attribute.
  • lazy: Defer loading of the resource until it reaches a calculated distance from the viewport.
  • eager: Load the resource immediately, regardless of where it’s located on the page.

Credits

  • Jekyll - A blog-aware static site generator in Ruby.
  • MultiMarkdown - Lightweight markup processor to produce HTML, LaTeX, and more.
  • markdown-it-multimd-table - Multimarkdown table syntax plugin for markdown-it markdown parser.
  • jmoji - GitHub-flavored emoji plugin for Jekyll.
  • jekyll-target-blank - Automatically opens external links in a new browser for Jekyll Pages, Posts and Docs.
  • jekyll-loading-lazy - Automatically adds loading="lazy" to img and iframe tags to natively load lazily.
  • mermaid - Generation of diagram and flowchart from text in a similar manner as markdown.

Contributing

Issues and Pull Requests are greatly appreciated. If you've never contributed to an open source project before I'm more than happy to walk you through how to create a pull request.

You can start by opening an issue describing the problem that you're looking to resolve and we'll go from there.

Download Details:

Author: jeffreytse
Source Code: https://github.com/jeffreytse/jekyll-spaceship 
License: MIT license

#jekyll #music #emoji #html