linux – Updating text in a Markdown document with Bash

This is a small script to update my project’s README file. Notes on improvements from any aspect are welcome!

Here is the document it updates.

readme.sh (Executed like so: ./readme.sh)

#!/usr/bin/env bash

export LANG=en_US.UTF-8
export LANGUAGE=en:el

set -eu

domain_linecount=$(cat black_domain.txt | wc -l)
ipv4_linecount=$(($(cat black_ipv4.txt | wc -l)-$domain_linecount))
ipv6_linecount=$(($(cat black_ipv6.txt | wc -l)-$domain_linecount))

domain_entries=$(printf "%'d" $domain_linecount)
domain_size=$(du -h black_domain.txt | gawk -F't' '{ print $1 }')

ipv4_entries=$(printf "%'d" $ipv4_linecount)
ipv4_size=$(du -h black_ipv4.txt | gawk -F't' '{ print $1 }')

ipv6_entries=$(printf "%'d" $ipv6_linecount)
ipv6_size=$(du -h black_ipv6.txt | gawk -F't' '{ print $1 }')

sed -i 
    -e "s/(<td id="domain-entries">).*(</td>)/<td id="domain-entries">$domain_entries</td>/g" 
    -e "s/(<td id="domain-size">).*(</td>)/<td id="domain-size">${domain_size}B</td>/g" 
    -e "s/(<td id="ipv4-entries">).*(</td>)/<td id="ipv4-entries">$ipv4_entries</td>/g" 
    -e "s/(<td id="ipv4-size">).*(</td>)/<td id="ipv4-size">${ipv4_size}B</td>/g" 
    -e "s/(<td id="ipv6-entries">).*(</td>)/<td id="ipv6-entries">$ipv6_entries</td>/g" 
    -e "s/(<td id="ipv6-size">).*(</td>)/<td id="ipv6-size">${ipv6_size}B</td>/g" ./.github/README.md
# xmlstarlet is probably better to handle this

visual studio code – vscode markdown preview not supporting some math commands

I’m writing markdown on vscode. But some math latex commands are not supported on vscode built-in preview. E.g.

$$ ket{psi} $$

cannot be properly rendered. How do I fix this? How do I add support to a bigger set of commands? Are there any extension that does this for me?

I installed markdown + math extension, but still not working for ket command. Also for some reason, markdown + math‘s official example for equation numbers supporting is not working. I don’t understand why.

r markdown – Remove_Column from a kable table which will be output as latex/pdf

I am trying to remove two columns from the below table however when knitted as a pdf from markdown I get the below error. I am unsure if this just isn’t possible or if there is a work around.

ERROR:
Error in remove_column(., 4:5) :
Removing columns was not implemented for latex kables yet
Calls: … kable_classic -> kable_light -> kable_styling -> remove_column
Execution halted

OverCortTab <- bind_rows(AlexOverCortTab$table_body,OptOverCortTab$table_body)%>% 
  mutate(Predictor=str_replace(Predictor,"TAS_Tot","Alexithymia"),
         Predictor=str_replace(Predictor,"OPT_Tot","Optimism"))%>%
  mutate(Fit=str_replace(Fit,"95%","95\\%"),
         Fit=str_replace(Fit,"R2","R$2$"),
         Fit=lead(Fit,n=2))%>%
        filter(Predictor !=""|Fit !="")%>%
        kable(caption = "Table 1: Hair Cortisol and Personality",
        booktabs=TRUE,
        col.names = c("Predictor","$\beta$","$\beta$ 95\% CI","$\beta$","$\beta$ 95\% CI","sr2","sr2 95\% CI","r","Fit"),
        escape=FALSE) %>%
        remove_column(4:5)%>% 
        kable_classic(font_size=12)%>%
  footnote(general=c("A Significant $\beta$-weight indicates the semi-partial correlation is also significant.","$\beta$ represents unstandardised regression weights.","sr2 represents the semi-partial correlation squared.","Square brackets are used to enclose the lower and upper limits of the confidence interval.","* indicates p < .05", "** indicates p < .01"),escape=FALSE) %>%
  group_rows("Alexithymia",1,2,hline_before=TRUE,hline_after=TRUE,underline=TRUE)%>%
  group_rows("Optimism",3,4,hline_before=TRUE,hline_after=TRUE,underline=TRUE) ```

Use fenced code blocks in pandoc markdown output

Is there a way to make pandoc output fenced code blocks (i.e. using triple backticks) when outputting markdown, rather than indenting with four spaces?

strings – Two Dimensional Array to Markdown Table Converter Implementation in C#

I am attempting to implement a converter which can convert two dimensional array (such as string(,)) into markdown table.

The experimental implementation

The experimental implementation of Converter class is as below.

public static class Converter
{
    /// <summary>
    /// Align formats
    /// </summary>
    public enum Align
    {
        Right,
        Center,
        Left,
        Default
    }

    private static TOutput(,) ConvertAll<TInput, TOutput>(TInput(,) array, Converter<TInput, TOutput> converter)
    {
        //    null check
        if (ReferenceEquals(array, null))
        {
            throw new ArgumentNullException($"{nameof(array)} is null");
        }

        if (ReferenceEquals(converter, null))
        {
            throw new ArgumentNullException($"{nameof(converter)} is null");
        }

        var output = new TOutput(array.GetLongLength(0), array.GetLongLength(1));
        for (long row = 0; row < array.GetLongLength(0); row++)
        {
            for (long column = 0; column < array.GetLongLength(1); column++)
            {
                output(row, column) = converter(array(row, column));
            }
        }
        return output;
    }

    /// <summary>
    /// ToMarkdownTable method with TInput type array
    /// </summary>
    /// <param name="input">Input array</param>
    /// <param name="align">Align format of all columns</param>
    /// <returns></returns>
    public static string() ToMarkdownTable<TInput>(TInput(,) input, Align align = Align.Default)
    {
        return ToMarkdownTable(ConvertAll(input, element => element.ToString()), align);
    }

    /// <summary>
    /// ToMarkdownTable method with TInput type array and the parameter for assigning align format of each column
    /// </summary>
    /// <param name="input">Input array</param>
    /// <param name="aligns">Align format of each column</param>
    /// <returns></returns>
    public static string() ToMarkdownTable<TInput>(TInput(,) input, Align() aligns)
    {
        return ToMarkdownTable(ConvertAll(input, element => element.ToString()), aligns);
    }


    /// <summary>
    /// ToMarkdownTable method
    /// </summary>
    /// <param name="input">Input array</param>
    /// <param name="align">Align format of all columns</param>
    /// <returns></returns>
    public static string() ToMarkdownTable(string(,) input, Align align = Align.Default)
    {
        Align() format = new Align(input.GetLongLength(1));
        Array.Fill(format, align);
        return ToMarkdownTable(input, format);
    }

    /// <summary>
    /// ToMarkdownTable method with assigning align format of each column
    /// </summary>
    /// <param name="input">Input array</param>
    /// <param name="aligns">Align format of each column</param>
    /// <returns></returns>
    public static string() ToMarkdownTable(string(,) input, Align() aligns)
    {
        //    Null check
        if (ReferenceEquals(input, null))
        {
            throw new ArgumentNullException($"{nameof(input)} is null");
        }

        if (ReferenceEquals(input, null))
        {
            throw new ArgumentNullException($"{nameof(aligns)} is null");
        }

        long width = input.GetLongLength(1);
        long height = input.GetLongLength(0);

        string() output = new string(height + 1);

        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.Append('|');
        for (int x = 0; x < width; x++)
        {
            stringBuilder.Append(input(0, x));
            stringBuilder.Append('|');
        }
        output(0) = stringBuilder.ToString();
        stringBuilder.Clear();

        stringBuilder.Append('|');
        for (int x = 0; x < width; x++)
        {
            switch (aligns(x))
            {
                case Align.Right:
                    stringBuilder.Append("-:|");
                    break;
                case Align.Center:
                    stringBuilder.Append(":-:|");
                    break;
                case Align.Left:
                    stringBuilder.Append(":-|");
                    break;
                case Align.Default:
                    stringBuilder.Append("-|");
                    break;
                default:
                    stringBuilder.Append("-|");
                    break;
            }
            
        }
        output(1) = stringBuilder.ToString();
        stringBuilder.Clear();

        for (int y = 1; y < height; y++)
        {
            stringBuilder.Append('|');
            for (int x = 0; x < width; x++)
            {
                stringBuilder.Append(input(y, x));
                stringBuilder.Append('|');
            }
            output(y + 1) = stringBuilder.ToString();
            stringBuilder.Clear();
        }
        return output;
    }
}

Test cases

The test cases of Converter.ToMarkdownTable methods include string, sbyte, byte, short, ushort, char and int type two dimensional arrays input.

//    string type two dimensional array case
Console.WriteLine("string type two dimensional array case");
string(,) test_string = { { "0", "1", "1", "1" },
                          { "2", "3", "1", "1" },
                          { "0", "1", "1", "1" }};

var format = new Converter.Align(test_string.GetLongLength(1));
for (int i = 0; i < test_string.GetLongLength(1); i++)
{
    format(i) = Converter.Align.Center;
}
var MarkdownTable = Converter.ToMarkdownTable(test_string, Converter.Align.Center);
for (int i = 0; i < MarkdownTable.Length; i++)
{
    Console.WriteLine(MarkdownTable(i));
}
Console.WriteLine();

//    sbyte type two dimensional array case
Console.WriteLine("sbyte type two dimensional array case");
sbyte(,) test_sbyte = { { 0, 1, 1, 1 },
                        { 2, 3, 1, 1 },
                        { 0, 1, 1, 1 }};

var MarkdownTable_sbyte = Converter.ToMarkdownTable(test_sbyte, Converter.Align.Center);
for (int i = 0; i < MarkdownTable.Length; i++)
{
    Console.WriteLine(MarkdownTable(i));
}
Console.WriteLine();

//    byte type two dimensional array case
Console.WriteLine("byte type two dimensional array case");
byte(,) test_byte = { { 0, 1, 1, 1 },
                      { 2, 3, 1, 1 },
                      { 0, 1, 1, 1 }};

var MarkdownTable_byte = Converter.ToMarkdownTable(test_byte, Converter.Align.Center);
for (int i = 0; i < MarkdownTable.Length; i++)
{
    Console.WriteLine(MarkdownTable(i));
}
Console.WriteLine();

//    short type two dimensional array case
Console.WriteLine("short type two dimensional array case");
short(,) test_short = { { 0, 1, 1, 1 },
                        { 2, 3, 1, 1 },
                        { 0, 1, 1, 1 }};

var MarkdownTable_short = Converter.ToMarkdownTable(test_short, Converter.Align.Center);
for (int i = 0; i < MarkdownTable.Length; i++)
{
    Console.WriteLine(MarkdownTable(i));
}
Console.WriteLine();

//    ushort type two dimensional array case
Console.WriteLine("ushort type two dimensional array case");
ushort(,) test_ushort = { { 0, 1, 1, 1 },
                          { 2, 3, 1, 1 },
                          { 0, 1, 1, 1 }};

var MarkdownTable_ushort = Converter.ToMarkdownTable(test_ushort, Converter.Align.Center);
for (int i = 0; i < MarkdownTable.Length; i++)
{
    Console.WriteLine(MarkdownTable(i));
}
Console.WriteLine();

//    char type two dimensional array case
Console.WriteLine("char type two dimensional array case");
char(,) test_char = { { '0', '1', '1', '1' },
                      { '2', '3', '1', '1' },
                      { '0', '1', '1', '1' }};

var MarkdownTable_char = Converter.ToMarkdownTable(test_char, Converter.Align.Center);
for (int i = 0; i < MarkdownTable.Length; i++)
{
    Console.WriteLine(MarkdownTable(i));
}
Console.WriteLine();

//    int type two dimensional array case
Console.WriteLine("int type two dimensional array case");
int(,) test_int = { { 0, 1, 1, 1 },
                    { 2, 3, 1, 1 },
                    { 0, 1, 1, 1 }};

var MarkdownTable_int = Converter.ToMarkdownTable(test_int, Converter.Align.Center);
for (int i = 0; i < MarkdownTable.Length; i++)
{
    Console.WriteLine(MarkdownTable(i));
}
Console.WriteLine();

The output of the above tests:

string type two dimensional array case
|0|1|1|1|
|:-:|:-:|:-:|:-:|
|2|3|1|1|
|0|1|1|1|

sbyte type two dimensional array case
|0|1|1|1|
|:-:|:-:|:-:|:-:|
|2|3|1|1|
|0|1|1|1|

byte type two dimensional array case
|0|1|1|1|
|:-:|:-:|:-:|:-:|
|2|3|1|1|
|0|1|1|1|

short type two dimensional array case
|0|1|1|1|
|:-:|:-:|:-:|:-:|
|2|3|1|1|
|0|1|1|1|

ushort type two dimensional array case
|0|1|1|1|
|:-:|:-:|:-:|:-:|
|2|3|1|1|
|0|1|1|1|

char type two dimensional array case
|0|1|1|1|
|:-:|:-:|:-:|:-:|
|2|3|1|1|
|0|1|1|1|

int type two dimensional array case
|0|1|1|1|
|:-:|:-:|:-:|:-:|
|2|3|1|1|
|0|1|1|1|

If there is any possible improvement, please let me know.

sharepoint online – MS Flow – Approval Email – Markdown Table

Since this a complex array, I used a combination of (Parse JSON) and (Apply to each) actions, and string functions to generate the HTML table to get the output as requested.

See the screenshots and explanation below.

enter image description here

varArray – a string variable, contains the array string that has been provided.

varHTMLTable – a string variable, initialized with a Table layout with some styles. See Expression 1.

Expression 1

<!DOCTYPE html>
<html>
<head>
<style>
th, td {
  border-left: 1px solid black;
  padding: 5px;
  width:200px;
}
th {text-align:left; }

</style>
</head>
<body>

<table style="width:50%">
  <tr>
    <th>Header</th>
    <th>Data</th> 
    <th></th>
  </tr>
<!--add a blank row between (Header) and (Data) Rows -->
  <tr>
    <td style="border:0px;">&nbsp;</td>
    <td style="border:0px;">&nbsp;</td>
    <td style="border:0px;">&nbsp;</td>
  </tr>

Detail 1

enter image description here

Expression 2

concat('<tr><td>', items('Apply_to_each')('Header')?(0), '</td><td>', items('Apply_to_each')('Data')?(0), '</td><td> </td></tr>',

'<tr><td>', items('Apply_to_each')('Header')?(1), '</td><td>', items('Apply_to_each')('Data')?(1), '</td><td> </td></tr>',

'<tr><td>', items('Apply_to_each')('Header')?(2), '</td><td>', items('Apply_to_each')('Data')?(2), '</td><td> </td></tr>'

)

Detail 2

enter image description here

The Final output seen in the email body

Note: Table styles can be adjusted as needed.

enter image description here

r markdown – How to enable the ioslides go to the next slide?

I am trying to generate an ioslide_presentation in RMarkdown (RStudio), and struggled with a very basic issue… I am noticing any presentation I generate does not navigate from one slide to the next with the mouse-click… Is that correct? What I am missing? This happens even in the browser with the knitted html file (edge, chrome)…

The header is simple like the following:

title: "Title"
author: "Author"
date: "04/01/2021"
output: 
  ioslides_presentation: 
    widescreen: yes
    smaller: yes

Any help or clarification is appreciated.

visual studio code – Markdown To PDF Supporting LaTeX And HTML in VSCode

I’m attempting to convert from Markdown to PDF in VSCode with the following requirements:

  1. Needs to support LaTeX
  2. Needs to support HTML/CSS
  3. Needs to support highlighting

I’m using the extension Markdown Preview Enhanced and have tried using the PDF converters it has (Puppeteer and Pandoc). This is what the output should look like (It’s a PNG though, not a PDF). For whatever reason the LaTeX is not rendering correctly, neither is the HTML.

I’m definitely open to using other extensions to convert the MDs to PDFs, any help would be great!

Other info:

  • Markdown Preview Enhanced uses Markdown-It to render the Markdown.
  • I’m using the following front matter for pandoc:

fontsize: 12pt
linkcolor: blue
urlcolor: green
citecolor: cyan
filecolor: magenta
toccolor: red
geometry: margin=0.3in
papersize: letter
output:
pdf_document:
highlight: tango

r markdown – Knitr keeps executing and cannot be cancelled after error

Every time I run into an error while knitting a script that stops execution, RStudio behaves in a weird way: In the R markdown tab it reads in red that the execution is stopped but in the R markdown tab I see the continuing progress circle still moving, suggesting that knitting is still ongoing. Also on the right hand I see that “stop” sign but clicking on it also does not stop executing. I can still write text in the script but I can no longer execute the script and can also not kick off a new knitting attempt.

enter image description here
The only way of going back to normal is top close Rstudio and re-start it. That means, everytime I run into any kind of error while knitting I have to restart Rstudio. This does not occur on my private PC with the same scripts.
I have installed a new version of Rstudio (the new 1.4 Preview) and I have re-installed R Markdown. Do you have any tips?

Markdown Monster 1.25.10 | Nulled Scripts Download

File size: 18.6 MB

Markdown Monster is a Markdown editor and viewer that lets you edit Markdown with syntax highlighting and fast text entry. A collapsible, synced, live preview lets you see your output as you type. You can easily embed images, links, emojis and code as text or by using our gentle UI helpers that simplify many operations. You can also paste and drag images directly into the editor. Inline spell-checking and word counts keep your content streamlined unobtrusively.

You can export Markdown to HTML by saving to disk or by copying Markdown selections as HTML directly to the clipboard. The HTML preview can display syntax colored code snippets for most common coding languages, and can easily be customized with HTML and CSS template to match your own sites. You can choose from a light and dark theme, and choose individual editor and preview themes. You can even use Vim or EMacs type conventions. Other convenience features let you browse for and select files in the built-in folder browser, jump to the current folder in Explorer or Terminal, commit to Git and more.

Weblog Publishing
Markdown Monster can also publish your Markdown directly to your Weblog. If your blog supports WordPress, MetaWeblog or Medium, you can publish your documents with one click. You can also edit and republish, or download existing posts and even convert existing posts from HTML to Markdown.

Extensible via .NET Addins
We also wanted to make sure the editor is highly extensible, so you can add custom features of your own. Markdown Monster includes an addin model that makes it easy to build extensions that let you hook into the UI, the editor behavior and the publishing process. We also provide useful .NET Scripting and Text Templating addins that let you automate many tasks without creating an addin. Find out more about creating an addin with .NET.

Markdown Editing and Weblog Publishing on Windows:
Syntax colored Markdown
Live HTML preview
Inline spell checking
Embed images, links and emoji
Paste images from Clipboard
Capture & embed screen shots
Save to Html and Pdf
Weblog publishing and editing
HTML to Markdown conversion
Editor and preview themes
Git Integration
Document Outline
Template text expansion
.NET scripting & addins

What’s new

HOMEPAGE

Download From Rapidgator

Download From Nitroflare

 

.