hugo-PaperMod/content/posts/code_syntax.md
2023-12-31 10:35:39 +05:30

3.2 KiB

author title date description summary tags categories series ShowToc TocOpen
Aditya Telange
Code Syntax Guide 2019-03-10 Sample article showcasing basic code syntax and formatting for HTML elements. Sample article showcasing basic code syntax and formatting for HTML elements.
markdown
syntax
code
gist
themes
syntax
Themes Guide
true true

Inline Code

This is Inline Code

Only pre

This is pre text

Code block with backticks

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>Example HTML5 Document</title>
    <meta
      name="description"
      content="Sample article showcasing basic Markdown syntax and formatting for HTML elements."
    />
  </head>
  <body>
    <p>Test</p>
  </body>
</html>

Code block with backticks and language specified

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>Example HTML5 Document</title>
    <meta
      name="description"
      content="Sample article showcasing basic Markdown syntax and formatting for HTML elements."
    />
  </head>
  <body>
    <p>Test</p>
  </body>
</html>

Code block with backticks and language specified with line numbers

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>Example HTML5 Document</title>
    <meta
      name="description"
      content="Sample article showcasing basic Markdown syntax and formatting for HTML elements."
    />
  </head>
  <body>
    <p>Test</p>
  </body>
</html>

Code block with line numbers and highlighted lines

  • PaperMod supports linenos=true or linenos=table
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>Example HTML5 Document</title>
    <meta
      name="description"
      content="Sample article showcasing basic Markdown syntax and formatting for HTML elements."
    />
  </head>
  <body>
    <p>Test</p>
  </body>
</html>
  • With linenos=inline line might not get highlighted properly.
  • This issue is fixed with 045c084
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>Example HTML5 Document</title>
    <meta
      name="description"
      content="Sample article showcasing basic Markdown syntax and formatting for HTML elements."
    />
  </head>
  <body>
    <p>Test</p>
  </body>
</html>

Code block indented with four spaces

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Example HTML5 Document</title>
</head>
<body>
  <p>Test</p>
</body>
</html>

Code block with Hugo's internal highlight shortcode

{{< highlight html >}}

<!doctype html>

<html lang="en"> <head> </head>

Test

</html> {{< /highlight >}}

Github Gist

{{< gist adityatelange 376cd56ee2c94aaa2e8b93200f2ba8b5 >}}