Jekyll Markdown html entity - jekyll

I have a Jekyll website and I ofter use markdown (with kramdown) syntax for the posts.
I want that if I write in a .md file:
Lui esaminò la città e la trovò molto bella mentre ora è uno schifo
The result html will be:
Lui esaminò la città e la trovò molto bella mentre ora è uno schifo
Now it doesn't put the html entity, better it changes only lsquo rsquo ldquo and rdquo
How can achieve this results?

I would use utf-8 encoding in the HTML to prevent this problem.

I also encountered this issue at the very beginning when dealing with Chinese characters.
You may need to add <meta charset="utf-8"> in <head>...</head> part of your template layout, and then html will display correctly in the browser.

Related

How to write a textarea similar to facebook/linkedin to write comments or posts on Angular?

I'm building a social network and I want to use a good way to let my users write their posts and comments.
I say, I dont want to use textarea to write the post/comment, I want to use something like facebook/linkedin-like text editor(or textarea), which can reside automaticly while users type.
So far, I have searched a lot and tryied to find a way to solve it, but I couldn't find any solution.
I ended up using "contenteditable" on a div, add a (input) event on it, and a textarea with display none which takes the string from the div with contenteditable sets to true with two way data biding.
One of the problem I found is that the textarea value gets I lot of "\n" character while if the editor breacks the line or me press enter. Actually I don't know if this is a problem or is safe.
Here is the code:
In template:
<div class="container">
<div class="editor" contenteditable="true" data-placeholder="No que você está pensando?" aria-placeholder="No que você está pensando?" aria-label="Editor de texto para criação de conteúdo" role="textbox" data-test-ql-editor-contenteditable="true" (input)="takeBlank($event)">
</div>
<textarea [(ngModel)]="teste" name="" id="" cols="30" rows="10">
</textarea>
</div>
I inspected the linkedin/facebook page, and I saw that they didnt use any form tag to get the post/comment value, they both use contenteditable div. Or simply I couldn't see ;).
Now, it's working fine. It resizes and get values, puts the value to a textarea and retrieve it again and perfom the submition.
I don't to go through I bad way of doing things, I want the best practice and keep it very secure, safe and not vulnerable.
Please tell me, is it a good aproach to fallow or is there a best way and simple,and requires a minimal of size of files to do this?

latex \textbackslash does not work, rmarkdown html

I want to include the \textbackslash in a latex math formula in a rmarkdown html document. I am working with bookdown. here is a sample code:
---
title: "Probabilidad"
author: "Nicolás Molano Gonzalez"
date: "7 de Abril de 2020"
output:
bookdown::html_document2: default
---
here is some useless text
now I want to do this $A \textbackslash B$ but it does not work properly
The $A \textbackslash B$ is not working
You can use \setminus, \smallsetminus or \backslash instead. The problem is that bookdown::html_document2 is using MathJax, and by design it only handles math-mode macros. See here for a discussion of the differences.

How do I extract only the url from this element?

What xpath should i use to extract only the url link from the below element?
<a class="url" rel="noreferrer" onclick="redirect('https://www.fotbollskanalen.se/allsvenskan/kujovic-siktar-pa-startplats-var-naturligt-att-agera-inhoppare---nu-vill-jag-s');">Läs mer på Fotbollskanalen</a>
I have tried using the below xpath, but it only returns "Läs mer på Fotbollskanalen" and not the url itself.
a[1]/child::node()
Also tried different versions attempting to set specify the class but unable to get it right.
Try this:
substring-before(substring-after(//a/#onclick, "'"),"'")
It will,
substring-before(substring-after(foo, "'"),"'"):
Get in everything enclosed by ' in foo.
//a: Of the element a.
/#onclick: Inside the attribute onclick.

Special HTML characters in meta tag description

My metatag description contains a text with accents or special caracteres.
I'm creating it in Controller MVC and I send to view through of viewbag.
By the way, my text html (when I use browser's view HTML sourcecode) is getting with a different code.
Example:
orign text: Produtor's Event em 10 Kirkpatrick St, até N...
html text: Produtor's Event em 10 Kirkpatrick St, at&#233...
I need to care about this? Or I need to correct to a new code? How can I?
The solution is easier.
Use #Html.Raw
<meta name="description" content="#Html.Raw(ViewBag.description)" />

HTML 5 lang attribute not working as expected

I'm trying to create a website that supports multiple languages with the help of the HTML lang attribute. I've found this example here:
<!DOCTYPE html>
<html>
<body>
<p>This is a paragraph.</p>
<p lang="fr">Ceci est un paragraphe.</p>
</body>
</html>
I've defined german as language in my OS and tried this with different browsers, but I always see the french paragraph as well. That's what I see:
This is a paragraph.
Ceci est un paragraphe.
The lang attribute specifies the language of the element’s content. Everything else is up to the user-agent resp. the webmaster.
Example uses:
a screen reader may use it to use the appropriate pronounciation
a browser may use it to use syllabification
a search engine may use it to find relevant content
a webmaster may use it to style content accordingly, e.g. using the correct quotation marks for the q element with CSS’s quotes
By no means should user-agents hide content in a different language by default. Think of these examples:
<p lang="en">I met a nice guy there. His name was <span lang="de">Max Mustermann</span>.
<p lang="en">He said to me <q lang="de">Halt! Stopp!</q>.</p>
<p lang="en">The original title is <cite>Faust. Eine Tragödie.</cite>.</p>
When content in different languages would be hidden, they would read:
I met a nice guy there. His name was .
He said to me .
The original title is .
It seems you want to use it to realize a multilingual page. While this is possible with JS/CSS, it’s usually not the best way. Typically you might want to use separate pages for each language and link the translation with the link type alternate and the corresponding hreflang:
<!-- on the page <example.com/en/about-me>, you could link to the German translation -->
<link rel="alternate" hreflang="de" href="/de/ueber-mich" />
The lang attribute goes on the HTML tag for the whole page, and specifies what the default language of the page is. It's metadata that describes the content. What you're trying to do with it isn't what it does.
You could do what you're trying to do by using JQuery to hide all tags in the page which have a lang attribute not equal to something you specify, but you'd have to research how to discover what the system language is in the browser (assuming that's possible). If you don't want to drag JQuery into it, you could just walk the DOM yourself.