When I use
``# ``
in my Sphinx documentation I get the following warning:
WARNING: Inline literal start-string without end-string.
Trying
:samp:`# `
leads to
WARNING: Inline interpreted text or phrase reference start-string without end-string.
The problem seems to be the trailing whitespace however I couldn't figure out a way of getting around this problem. Escaping the whitespace with a backslash (\) doesn't help either (for the first example the warning persists and for the second example the whitespace is omitted in the generated docs).
This answer doesn't work because the inline code section interprets the |space| as a literal string.
Experienced with Sphinx 1.6.2.
A workaround is to use a no-break space character (U+00A0) instead of a regular space (U+0020) for the trailing whitespace.
There are several ways to insert a literal no-break space character. See https://en.wikipedia.org/wiki/Non-breaking_space#Keyboard_entry_methods.
Use a "literal" role__ with an escaped space after the intended trailing space::
:literal:`# \ `
__https://docutils.sourceforge.io/docs/ref/rst/roles.html#literal
Related
I have a - in my regular expression. When I run it, I get warning: character class has '-' without escape: /[^a-zA-Z0-9-_\\.]/
How can I silence this warning?
At this place [^a-zA-Z0-9-_\\.] there is a possibility of an error. Usage of '-' either means the new range(with mistyping) or just a symbol. Either move single characters in front of ranges or prefix with '\'
verbosity = $VERBOSE
$VERBOSE = nil
/[^a-zA-Z0-9-_\\.]/ #=> /[^a-zA-Z0-9-_\\.]/
$VERBOSE = verbosity
Add a backslash (\) to escape the lonely dash. It appears the offending dash is immediately after [^a-zA-Z0-9. Add \- instead of just the dash character -. The full regex including the minor change is
/[^a-zA-Z0-9\-_\\.]/
This will remove the warning. Escaping it with the backslash clearly instructs the regex engine that you mean to search for that character and not that you forgot to complete a range like [a-z]
Is it possible in Yaml to have multi-line syntax for strings without an additional character generated between newlines?
Folded (>) syntax puts spaces, literal syntax (|) puts newlines between lines.
The summary here does not give a solution: In YAML, how do I break a string over multiple lines?.
E.g.
>-
line1_
line2
generates line1<space>line2 - I would like to have line1_line2 without additional token.
Use a double-quoted string:
"line1_\
line2"
By escaping the newline character, it is completely removed instead of being translated into a space. It is not possible to do this with block scalars because they have no escape sequences.
I want to split a string (insecure foreign line, like exim_mainlog line) by spaces, but not by spaces that are inside of double quotes, and ignore if the quote is escaped by a backslash like \", and ignore the backslash if it is just escaped like \\. Without slow parsing the string manually with FSM.
Example line:
U=mailnull T="test \"quote\" and wild blackslash\\" P=esmtps
Should be split into:
["U=mailnull", "T=\"test \\\"quote\\\" and wild blackslash\\\"", "P=esmtps"]
(Btw, I think ruby should had method for such split.., sigh).
I think I found simple enough solution: input.scan(/(?:"(?:\\.|[^"])*"|[^" ])+/)
I read similar titles but I couldn't make it run..
Now, I have a code like this (originally ereg):
if (preg_match("[^0-9]",$qrcode_data_string)){
if (preg_match("[^0-9A-Z \$\*\%\+\-\.\/\:]",$qrcode_data_string)) {
I also tried using / at the beginning and end of rule but didn't work.
Any replies welcome.
With the preg_* functions you need delimiters around the pattern:
if (preg_match("#[^0-9]#", $qrcode_data_string)) {
# ^ ^
From the documentation:
When using the PCRE functions, it is required that the pattern is enclosed by delimiters. A delimiter can be any non-alphanumeric, non-backslash, non-whitespace character.
Often used delimiters are forward slashes (/), hash signs (#) and tildes (~).
I'm a bit stuck on this issue. I'm trying to make a newline using '\n'. I'm opening a file, then replacing the text, then writing it back as an html file:
replace = text.gsub(/aaa/, 'aaa\nbbb')
But this results in:
aaa\nbbb
I'm trying to make do:
aaa
bbb
In single-quoted strings a backslash is just a backslash (except if it precedes another backslash or a quote). Use double quotes: "aaa\nbbb" .
You'll want to read:Backslashes in Single quoted strings vs. Double quoted strings in Ruby?.