list numbering get reset after sections - restructuredtext

Why is the third #. not a 3 and how is possible to continues numbering?
============
Part title..
============
#. sss
#. ddd
***************
Chapter title..
***************
#.

Related

Nested numbered list do not break line in Jupyter Notebook Markdown

I'm trying to create a nested numbered list within a Jupyter Notebook Markdown cell for use as a table of contents which links to titles in the document. However the items in the list which should be nested/indented just appear on the same line when the cell has been executed.
I have tried using four spaces before the numbers I want indenting (which is what I've seen people suggesting). This didn't work so I also tried 1-3 spaces and using a tab but none seem to work. Thought it may be an issue with the numbering itself and the use of fullstops (i.e. "1." and "1.1" , and not "1.1." etc), but this doesn't fix the issue either.
The indent does work if i use an asterisk in place of 1.1, 1.2 etc., but this is not the format I want.
Markdown code example:
1. [Intro](#intro)
1.1 [Part A](#pA)
1.2 [Part B](#pB)
1.3 [Part C](#pC)
2. [Main](#main)
This code outputs:
1. Intro 1.1 Part A 1.2 Part B 1.3 Part C
2. Main
Desired output:
1. Intro
1.1 Part A
1.2 Part B
1.3 Part C
2. Main
You need to add one of the following:
two white spaces at the end of each line, or
a <br> tag at the end of each line.
for instance:
1. [Intro](#intro)<br>
1.1 [Part A](#pA)<br>
1.2 [Part B](#pB)<br>
1.3 [Part C](#pC)<br>
2. [Main](#main)<br>
Results:
To create a numbered list, enter 1. followed by a space, for example:
1. Numbered item
1. Numbered item
For simplicity, you use 1. before each entry. The list will be numbered correctly when you run the cell.)
To create a substep, press Tab before entering the numbered item, for example:
1. Numbered item
1. Substep
Source (scroll down to "Numbered lists"): https://www.ibm.com/docs/en/watson-studio-local/1.2.3?topic=notebooks-markdown-jupyter-cheatsheet

Indent without adding a bullet point or number in RMarkdown

I want to make an indented list, but I don't want it to have bullet points or numbers. I am using Rmarkdown in RStudio, and knitting to html.
#### bla bla bla
* Example indented line with bullet point
* Another indent with another bullet point
* Yea this is good except for the stupid bullets!
1. Example indented line with numbers
* sure and an indent with a bullet too
2. But there's these stupid numbers now!
two spaces doesn't indent at all
or nest indent with 4
yea still no indent with 2.
four spaces ALSO doesn't indent
just makes some stupid code
why do you hate indents rmd??
This can be achieved using Line Blocks which are built-in to the R Markdown syntax. If you want the indentation to be respected, you can start a line with |.
This approach works across multiple output formats and doesn't require any additional CSS styling:
---
output:
html_document: default
pdf_document: default
---
Here is some text with no indentation
| A list
| A sublist
| Sublist Item 2
| Sublist Item 3
If you want to change how a list looks and you're outputting to HTML, use css:
---
title: "ListTest"
output: html_document
---
<style>
.nobullet li {
list-style-type: none;
}
</style>
<div class="nobullet">
* This list
* Doesn't have bullets
</div>
* This list
* Is normal
This won't work for other output formats.

Dynamic Rstudio Code Snippet

I tend to use a lot of line breaks in my code like the following:
# Data =========================================================================
Where the entire comment is always 80 characters long (including the hashtag). What I would like to do is write a code snippet for Rstudio that will insert the hashtag, then a space, then allow the user to type out a series of words, then insert another space, and finally fill in a bunch of "=" until the 80 character limit is reached.
I'm not familiar with how snippets work at all so I'm not sure how difficult this is.
I have this much:
snippet lb
# ${1:name}
but I have no idea how to add a dynamic number of "=" signs. Also, lb = linebreak.
You can't do this with snippets, unfortunately; a snippet is a text template that contains fixed text with slots for user-inserted text.
There is a command built into RStudio to do something very similar, however; from the Code menu, choose Insert Section (or Ctrl+Shift+R). This will do exactly what you're describing, with two small differences:
The line will extend to 5 characters before the print margin (you can adjust the print margin in Tools -> Global Options -> Code.
The line is composed of - rather than = characters.
One advantage to sections marked in this way is that you can use them to fold and navigate inside the file (look at the editor status bar after adding one).
You can use the rstudioapi (which can return column position) inside the snippet to get something like what you want.
Below is a snippet I use called endhead. I use it by commenting my header title and then applying the snippet, eg:
# Section name endhead
which results in:
# Section name -----------------------------------------------------------------
snippet endhead
`r paste0(rep.int("-", 88 - rstudioapi::primary_selection(rstudioapi::getActiveDocumentContext())$range$start[2]), collapse = "")`
You can write a snippet to manipulate text (somewhat). I wrote the snippet below to do something similar to what you want to do. I'm still ironing out the issues (just asked this question).
snippet comm
`r paste0(
"#######################################><###################\n## ",
date(),
" -------------------------------\n## ",
eval(
paste0(
gsub(
".{1,51}\\s?\\K\\b",
"\n## ",
gsub("\\.", " ", paste0(text)),
perl = T
)
)
),
"###################################><###################\n"
)`
I think if you write an R code snippet using an anonymous function that accepts text input via $$, counts the nchar in the text, calculates the number of -'s needed at the end, and then uses eval(paste0()) to insert the comment you should be able to make it work. I'll post a comment or answer here if I figure it out. Please do the same on my question if you get it to work. Thanks. (P.S. Go Badgers!)
Inspired by nick's answer above I designed two snippets that allow the user to choose what level section to insert.
The first will fill-in the rest of the line with #, =, or -.
snippet end
`r strrep(ifelse(substr("$$", 1, 1) %in% c("-", "="), substr("$$", 1, 1), "#"), 84 - rstudioapi::primary_selection(rstudioapi::getActiveDocumentContext())$range$start[2])`
Just specify the character you want to use after end (will default to # if nothing or any other character is given). For example:
## Level 1 Header end<shift+tab>
## Level 2 Header end=<shift+tab>
## Level 3 Header end-<shift+tab>
end<shift+tab>
end=<shift+tab>
end-<shift+tab>
Produces the following lines:
## Level 1 Header ##############################################################
## Level 2 Header =============================================================
## Level 3 Header -------------------------------------------------------------
################################################################################
===============================================================================
-------------------------------------------------------------------------------
Similarly to what Josh was suggesting, the following snippet uses th $$ notation to pass the text following the snippet as described here.
snippet !
`r paste("##", substr("$$", 4, nchar("$$")), strrep(substr("$$", 2, 2), 79-nchar("$$")))`
Again this allows user to select the section level (#, =, or -). The first character after !# should be the header level character you want followed by a space and the header text. For example:
!## Level 1 Header<shift+tab>
!#= Level 2 Header<shift+tab>
!#- Level 3 Header<shift+tab>
Produces the following lines:
## Level 1 Header ##############################################################
## Level 2 Header ==============================================================
## Level 3 Header --------------------------------------------------------------
I prefer the end snippet above because it is more robust and only allows the characters #, =, or - to be inserted where as ! will allow anything, but it is shorter and, I think, easier to understand than calls to the rstudioapi.
!loon<shift+tab>
## n ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo

Reading text file till a certain line in R

I am trying to read data from text file like below and want to create a data frame with information that I want.
junk
junk
------------------------------
Name number address
------------------------------
xyz 123 xxxxxx
abc 345 yyyyyy
------------------------------
junk
------------------------------
Name number address
------------------------------
bcv 789 zzzzzzz
------------------------------
junk
I am trying to create a data frame like below from above text file consolidating all similar information from my file.
Name number address
xyz 123 xxxxxx
abc 345 yyyyyy
bcv 789 zzzzzzz
I am using grep("^Name", input) and then reading lines below that. Please let me know how do I stop reading once I find dotted lines(---) and then continue adding records to data frame when I find "^Name" again in my text document.
Thanks,
Manjunath

How to force line break in Symfony2 translation file

In my messages.en.yml I have an entry that is used for an email body which is in plaintext, so I cannot use any HTML tags. Now when I need a line break and I add a blank line after, the line break appears in my email body.
But when I try to do a line break with a non empty line following, it does not break the lines.
email:
subject: My Subject
message: >
Hello %name%,
This is my second line
Best regards,
John Smith
Customer Care
Arrives like this in my mailbox
Hello Tom,
This is my second line
Best regards, John Smith Customer Care
I've tried to play around with HTML tags or with the \n which I know from PHP. But if I use <br> or <br /> in the translation file and apply the |raw filter in my twig file, the HTML tags still appear in my email body. And also if I use \n to force a line break, no line break is given and instead, the \n appear in my email as well.
Now how can I force the line break if a non empty line is following?
Use |
email:
subject: My Subject
message: |
Hello %name%,
This is my second line
Best regards,
John Smith
Customer Care
In your translations file (e.g. messages.en.yml):
your
translation
key:
here: |
Lorem ipsum.
CRMPICCO.
www.crmpicco.co.uk.
Accessing it in your Twig template:
{{ 'your.translation.key.here'|trans|nl2br }}

Resources