Can I Include a URL Link Within a Chunk of Code in a Github Markdown Document? - url

I'm looking to propose some small tweaks/improvements to my employer's coding standard written in Github markdown (*.md).
I've prepped by reviewing a couple of references this markdown language's formatting conventions.
From my readings I see that I can add URLs in at least two different ways:
Standard HTML:
TEXT
Markdown style links:
[TEXT](LINK_URL)
...and code markdown is written as:
Markdown style:
```LANGUAGE
MY CODE;
```
Implicit code denotation via 4 space indent.
However, I've been unable to find a reference on whether you can include a hyperlink inside a block of code (i.e. to the location of that object's source in your repository).
i.e. I want to do something like:
```javascript
_myQObject: <a title="QML Source for MyQObject" href="URL_TO_SOURCE">MyQObject {}
```
That does not work, however, and I've been unable to find documentation explicitly stating whether this is possible or not.
How can I include a link to a URL within a chunk of formatted Github markdown?
Is this possible?
For reference the basic style guides I've reviewed are:
Github Guides: "Mastering Markdown"
Adam-P's "Markdown Cheatsheet"

How can I include a link to a URL within a chunk of formatted Github markdown?
As far as I know this is not possible.
The original Markdown specification says:
With a code span, ampersands and angle brackets are encoded as HTML entities automatically, which makes it easy to include example HTML tags.
…
Regular Markdown syntax is not processed within code blocks. E.g., asterisks are just literal asterisks within a code block. This means it’s also easy to use Markdown to write about Markdown’s own syntax.
I haven't seen anything in the GitHub Markdown docs to suggest that they have added support for links in code blocks, and nothing I've tried has worked.
I also haven't seen this feature in any other Markdown implementations.

This is a late reply, but for people who come here hoping for a solution, there is a way to add links inside preformatted blocks. If you use an HTML block with <pre> ... </pre> instead of using the code block formatting sequence (i.e., don't use fenced code blocks or indented code blocks), you can then use <a> elements inside the preformatted text block. E.g.
<pre>
myQObject: MyQObject {}
</pre>
You lose the automatic syntax highlighting provided by "proper" code blocks, so there is a tradeoff.

Related

Customize quoted strings in VS Code

The value side of attributes in HTML were very unreadable, too dark, making it especially hard to disseminate between class names in HTML, when using the dark theme on VS Code.
How do I change it to make reading more comfortable?
p.s. My "Tags" are very limited due to rep, but I'm so sure others have this question.
Here is how to accomplish this particular task.
Introducing [me to] a very useful tool: Inspect Editor Tokens and Scopes
Put cursor in, in this case, a quoted value string.
CNTL + SHIFT + P (open command palette).
Find "Developer: Inspect Editor Tokens and Scopes"
Note the textmate scope(s).
Use property: "editor.tokenColorCustomizations" → "textMateRules" to add new rule.
While I'm doing this directly on values in the JSON of settings - and changing quotes there at a high level, this also works with inheritance, so string.quoted.double.html would override the example shown in this screenshot (which applies to ALL double quoted strings), when editing HTML files. I find this useful for making my lint rules standout too.

How to render LaTeX/PDF with a forced line break on a definition list in reStructuredText

I want to render a pdf file in reStructuredText with a proper line break, such that:
Keyword
Definition
This renders correctly with a Read the Docs template, but it doesn't produce the line break when using default settings and make latexpdf. Is there a simple function I can apply to the LaTeX output options in conf.py for this issue?
Note: I already submitted this question on TeX and was told to try Stack Overflow. The snippet above should be the shortest code required to reproduce my use case. As I said, these are the default settings as far as I know. I haven't made any significant changes. The lack of line break over definition lists seems to be the intended output for LaTeX pdf files.
Using the rinohtype PDF builder for Sphinx allows for fine control of style aspects such as these. The default style sheet actually inserts line breaks between a keyword and its definition in definition lists. Otherwise the style of the produced PDF is very similar to the output of the LaTeX builder. You can create your own style sheet and template configuration to customize the look of the PDF to your needs.
(Full disclosure: I am the author of rinohtype)
Here's a partial answer, to the limit of my knowledge. I hope it gets you further along.
By default the conversion applies a bold style to the term, and the definition of the term is inline with the term and line wraps with an indent on subsequent lines. See screenshot below for example output from the PDF for Pyramid documentation.
When you do make latexpdf you invoke two processors in succession, converting reST files to a LaTeX file, then running those files through pdflatex to generate the PDF.
Here's what appears for the first glossary entry in pyramid.tex for the first step:
\item[{ACE\index{ACE|textbf}}] \leavevmode\phantomsection\label{\detokenize{glossary:term-ace}}
An \sphinxstyleemphasis{access control entry}. An access control entry is one element
in an {\hyperref[\detokenize{glossary:term-acl}]{\sphinxtermref{ACL}}}. An access control entry is a three-tuple that
describes three things: an \sphinxstyleemphasis{action} (one of either \sphinxcode{Allow} or
\sphinxcode{Deny}), a {\hyperref[\detokenize{glossary:term-principal}]{\sphinxtermref{principal}}} (a string describing a user or
group), and a {\hyperref[\detokenize{glossary:term-permission}]{\sphinxtermref{permission}}}. For example the ACE, \sphinxcode{(Allow,
'bob', 'read')} is a member of an ACL that indicates that the
principal \sphinxcode{bob} is allowed the permission \sphinxcode{read} against the
resource the ACL is attached to.
The question now boils down to how to change that output so that it can be styled as you desire. And for that, you'll need to parse through the Sphinx documentation on LaTeX customization. How to do that is beyond my knowledge.
You can achieve that with a substitution to inject raw LaTeX code.
Keyword
|br| Definition
Keyword2
|br| Long definition long definition long definition long definition long
definition long definition long definition long definition long definition
long definition long definition long definition long definition long
definition long definition long definition long definition long definition
long definition long definition long definition long definition long
definition long definition long definition
.. |br| raw:: latex
\mbox{}\newline
This produces in PDF:
Note that the raw LaTeX code is not injected into other targets, only the latexpdf target.

Change format of inline code evaluation in org-mode's LaTeX-export

I have a code block in an org document
#+NAME: result_whatever
#+BEGIN_SRC python :session data :results value :exports none
return(8.1 - 5)
#+END_SRC
which I evaluate inline:
Now, does this work? Let's see: call_result_whatever(). I'd be surprised ...
When exporting to LaTeX, this generates the following:
Now, does this work? Let's see: \texttt{3.1}. I'd be surprised \ldots{}
However, I don't want the results to be displayed in monospace. I want it to be formatted in "normal" upright font, without any special markup.
How can I achieve this?
You should be able to get it work using the optional header arguments which can be added to call_function().
I don't have LaTeX installed on this system so can't fully test the outputs to ensure they come out exactly as desired, I'm using the plain text output to compare instead. However you can use the following syntax as part of your call to modify the results.
Now, does this work? Let's see call_results_whatever()[:results raw].
I'd be surprised ...
Without the [:results raw] the output to Plain Text (Ascii buffer) is Let's see `3.0999999999999996'.. With the added results it becomes Let's see 3.0999999999999996.
For full details of the available results keywords as well as other optional header arguments for the inline blocks please see Evaluation Code Blocks and Results arguments.
this is 5 years later. apparently in org-mode 8.2 or so, a new variable was introduced (documenting in "Evaluating Code Blocks" in the org-mode manual, but this from etc/ORG-NEWS in the source tree):
*** New option: org-babel-inline-result-wrap
If you set this to the following
: (setq org-babel-inline-result-wrap "$%s$")
then inline code snippets will be wrapped into the formatting string.
so, to eliminate \texttt{}
(setq org-babel-inline-result-wrap "%s")
The problem of this type can be solved in two ways:
1: Easy does it:
A plain query-replace on the exported buffer.
Once you're in the LaTeX buffer,
beginning-of-buffer or M-<
query-replace or M-%
enter \texttt as the string that you want to replace
enter nothing as the replacement
continue to replace each match interactively
with y/n or just replace everything with !
2: But I wanna!
The second way is to nag the org-mode mailing list into
implementing a switch or an option for your specific case.
While it's necessary sometimes, it also produces a system
with thousands of switches, which can become unwieldy.
You can try, but I don't recommend.

How to display plain text from markdown [duplicate]

I'm currently using BlueCloth to process Markdown in Ruby and show it as HTML, but in one location I need it as plain text (without some of the Markdown). Is there a way to achieve that?
Is there a markdown-to-plain-text method? Is there an html-to-plain-text method that I could feel the result of BlueCloth?
RedCarpet gem has a Redcarpet::Render::StripDown renderer which "turns Markdown into plaintext".
Copy and modify it to suit your needs.
Or use it like this:
Redcarpet::Markdown.new(Redcarpet::Render::StripDown).render(markdown)
Converting HTML to plain text with Ruby is not a problem, but of course you'll lose all markup. If you only want to get rid of some of the Markdown syntax, it probably won't yield the result you're looking for.
The bottom line is that unrendered Markdown is intended to be used as plain text, therefore converting it to plain text doesn't really make sense. All Ruby implementations that I have seen follow the same interface, which does not offer a way to strip syntax (only including to_html, and text, which returns the original Markdown text).
It's not ruby, but one of the formats Pandoc now writes is 'plain'. Here's some arbitrary markdown:
# My Great Work
## First Section
Here we discuss my difficulties with [Markdown](http://wikipedia.org/Markdown)
## Second Section
We begin with a quote:
> We hold these truths to be self-evident ...
then some code:
#! /usr/bin/bash
That's *all*.
(Not sure how to turn off the syntax highlighting!) Here's the associated 'plain':
My Great Work
=============
First Section
-------------
Here we discuss my difficulties with Markdown
Second Section
--------------
We begin with a quote:
We hold these truths to be self-evident ...
then some code:
#! /usr/bin/bash
That's all.
You can get an idea what it does with the different elements it parses out of documents from the definition of plainify in pandoc/blob/master/src/Text/Pandoc/Writers/Markdown.hs in the Github repository; there is also a tutorial that shows how easy it is to modify the behavior.

Markdown code indentation with HAML

I've been digging around for an answer for this since yesterday, and I'm stumped as to why is occurring...
We're delivering Markdown content through standard HAML templates (we're using the excellent static site generator Middleman to build, FYI), and Redcarpet to parse Markdown.
Everything is working as expected in terms of Markdown output, with the exception of code blocks:
layout.haml (only a part of the file, showing a simple =yield. This %section is intended 6 spaces in the HAML file):
%section.content.main_content
= yield
index.html.md (only a part of the file, showing the code block code)
### Header Level 3
Here's some code:
$total-columns : 12;
$column-width : 4em;
$gutter-width : 1em;
$grid-padding : $gutter-width;
The output though, is not what we are expecting, and something is messing around with indentation. I'm unsure if HAML is the culprit, or what exactly is causing it:
Here is a screenshot of the browser output: http://bit.ly/JvjTYo
Here is a screenshot of the DOM from Chrome Developer Rools: http://bit.ly/JWprGO
We've tried a few different Any help is VERY welcome. If you want to see the full source on GitHub, let me know.
Have a look at the Haml docs on whitespace. In this case you should be able to fix it by using the ~ operator instead of =:
%section.content.main_content
~ yield
I have a feeling this is HAML. It seems like it's trying to interpret and indent for you.
Do you have :ugly output on?
Also, do you have the below set for your pre tags?:
pre { white-space:pre }
EDIT: Found this Markdown Line Breaks in Code Blocks which might help

Resources