Chapter titles in the Header of a document generated by Asciidoctor-PDF - asciidoctor

I'd need to add the Chapter title in the page's heading of PDF files generated with Asciidoctor-toPDF.
Here is the set of Properties I'm using at the beginning of my doc:
= Book title
:notitle:
:toc: left
:toclevels: 8
:sectnums:
:sectnumlevels: 8
:source-highlighter: coderay
:icons: font
:chapter-label:
:header_recto_content_center: '{section-title}'
Is there any property I am missing or which conflicts with the Header generation?

A few theme-related attributes exist. But header is not one of them unfortunately.
So to style the header of a PDF one must resort to a custom style in YAML format.
Style
For this example the file is named style.yml and placed in our working directory.
extends: default #1
header:
height: 15mm #2
recto: &header #3
center-content: '-- {section-or-chapter-title} --' #4
verso: *header #5
Extends the default asciidoctor-pdf theme with your customized code.
Define the height of the header or the content will not show; also explained here.
Create a YAML anchor to the whole content of recto.
The use of {section-or-chapter-title} is explained and shown at the end of the post.
Reference the content from &header. In plain make verso behave the same as recto.
Document
The content of the adoc file is as shown below. The file is aptly named book.adoc and placed in the same directory as style.yml.
= Book title
:notitle:
:toc: left
:toclevels: 8
:sectnums:
:sectnumlevels: 8
:source-highlighter: coderay
:icons: font
:chapter-label:
== Chapter One
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
voluptua.
== Chapter Two
=== Section One
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
voluptua.
Conversion
PDF conversion is done using the pdf-stylesdir and pdf-style attributes.
asciidoctor-pdf -a pdf-stylesdir=. -a pdf-style=style.yml -d book book.adoc
Result
Chapter one looks then as shown in the screenshot. As there is no section header the chapter is used to populate the header.
Chapter two having both a chapter and a section defined is displaying the section title in the header.

Related

SwiftUI: "Censored" / Marked Text Effect

I'm trying to achieve a censored text look in SwiftUI. I've been placing a text and it's copy inside a ZStack and added a .background(Color.black) modifier to the front one. This works fine with single line texts. However, it doesn't look so good with multiline texts, as it results in a single black rectangle. Any ideas on how to achieve the look below with rather long, multiline texts?
For the sake of completeness, here's the simple code:
HStack{
Spacer()
.frame(width: 50)
ZStack {
Text("Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et")
.font(.system(.title2, design: .serif))
.foregroundColor(.blue)
.multilineTextAlignment(.trailing)
Text("Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et")
.font(.system(.title2, design: .serif))
.multilineTextAlignment(.trailing)
.background(Color.black)
}
}
As always, any help would be greatly appreciated!
If you’re targeting iOS 14, you could use the redacted(reason:) view modifier, which they added for widgets but works everywhere:
Text("View 0")
.redacted(reason: .placeholder)

How to replace word in text with link (Pug)?

I am a very beginner in Pug and I'm trying to solve the following task: Every occurrence (in text) of the following words shall become a link to the destination defined below:
sed -> https://google.com
liq -> https://facebook.com
Тhis works as I expected, but keeps anchor tag as string.
- var str = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Pulvinar elementum integer sed neque volutpat ac. Facilisis liq odio morbi quis commodo odio aenean . Vel facilisis volutpat liq velit. Viverra aliquet liq sit amet tellus cras adipiscing sed.";
- var url = '#[a(href="https://google.com") sed]'; //I tried with these ones too - var url = 'sed'; var url = 'a(href="https://google.com)sed'
- var res = str.replace(/sed/g, url);
p #{res}
Here my latest atempt:
mixin link(href, name)
a(href=href target!=attributes.target )= name
//+link('https://google.com', 'Google')(target="blank")
- var str = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Pulvinar elementum integer sed neque volutpat ac. Facilisis liq odio morbi quis commodo odio aenean . Vel facilisis volutpat liq velit. Viverra aliquet liq sit amet tellus cras adipiscing sed.";
- var link = +link('https://google.com', 'Google')(target="blank");
- var res = str.replace(/sed/g, link);
p #{res}
I've never seen Pug mixins used within javascript code blocks like that before. I'm surprised it even outputs the anchor tag at all.
That being said, you can use the unescaped string interpolation syntax (!{variable}) instead of the regular string interpolation syntax (#{variable}) to get the link to render as a link.
In your case:
p !{res}
But keep in mind this word of warning from the Pug documentation:
Caution
Keep in mind that buffering unescaped content into your templates can be mighty risky if that content comes fresh from your users. Never trust user input!

In VBA editor window, mouse selects next line instead of part of current one

This is my problem:
So, I want to select just a part of one (usually very long) line, and when I only slightly move my mouse down while moving to the right, the next line gets selected, and I can start over again.
Does anyone have a solution for this annoying mouse behavior?
Or would you recommend an altogether different input method? (pen, touch pad, keyboard, etc.)
Click on the start point of the text you want, then with the SHIFT key held down, click on the end point.
That's by design.
If you only wish to mark a part of one line, move mouse left-right only, not down (or up).
There are many possibilities to target your problem.
You can use your Shift-Key and the cursor keys to select.
You can also use your Shift-Key in combination with your End-Key and or Pos1-Key
You can also use your Shift-Key in combination with your mouse like mentioned by another user
Also the problem is not that big when you make shorter lines. In VBA you can use _ to hang lines together and interpret it like one:
txt = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."
is the same as
txt = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, " _
& "sed diam nonumy eirmod tempor invidunt ut labore et " _
& "dolore magna aliquyam erat, sed diam voluptua. At vero " _
& "eos et accusam et justo duo dolores et ea rebum. Stet " _
& "clita kasd gubergren, no sea takimata sanctus est Lorem " _
& "ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur " _
& "sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut " _
& "labore et dolore magna aliquyam erat, sed diam voluptua. At " _
& "vero eos et accusam et justo duo dolores et ea rebum. Stet " _
& "clita kasd gubergren, no sea takimata sanctus est Lorem ipsum " _
& "dolor sit amet."
To select the whole line you can also click at the white space between the gray bar on the left side of the editor and the first sign in the editor
I hope that helps you.

sublime text : how to fill paragraph?

In emacs, you can use meta-q "fill-paragraph" and in vim you can do gq - reformat paragraph (gggqG to fill the entire buffer)
Is there a similar key binding in sublime text?
Example:
Before fill-paragraph:
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam
After fill-paragraph:
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
minim veniam
New Answer
OK, so I misunderstood your original question - as I now understand it, MetaQ-"fill-paragraph" rearranges paragraphs into lines of approximately-equal lengths. There isn't a function that matches this exactly in Sublime, but you can (re)wrap lines quite easily. You can set the ruler in your Preferences.sublime-settings file, using the "wrap_width" setting. Then, using AltQ on Windows/Linux, or ⌘AltQ on OS X, you can wrap selected text to that width (it defaults to 78 characters if "wrap_width" is set to 0). If you want to wrap to other (pre-selected) widths, go to Edit -> Wrap and there are a number of other options. To set a preferred width outside of what is in your preferences, open Preferences -> Key Bindings - User and add the following:
[
// wrap lines at 25 characters
{ "keys": ["ctrl+alt+shift+w"], "command": "wrap_lines", "args": {"width": 25} }
]
You can obviously change the 25 to whatever value suits you. If you have no custom key bindings so far, copy and paste the entire contents above into the file. If you already have some key bindings, omit the outer square brackets, and remember to place a comma at the end of the line if it's not the final entry in the file. Good luck!

VIM: Insert a line number, with a space after

I need to insert the line number before each line of text using Vim, and there has to be a space after the line number. For example, if this was TestFile:
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Morbi nunc enim, vehicula eget, ultricies vel, nonummy in, turpis.
It should look like this
1 Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
2 Morbi nunc enim, vehicula eget, ultricies vel, nonummy in, turpis.
I have been using the command :%s/^/\line('.')/ with a number of variations, but I cannot figure out how to get the space at the end.
Any ideas?
You were very close!
This substitution will do the job by concatenating the string ' ' to the line number:
%s!^!\=line('.').' '!
This is probably easiest with an external tool:
:%!nl -ba -w1 -s' '
You can use a macro. First make sure you have a 0 before the first line and have your cursor placed on it:
0 Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Morbi nunc enim, vehicula eget, ultricies vel, nonummy in, turpis.
foo
bar
etc...
Then perform this key sequence to store the right macro in register a: qaywjP0<C-A>q.
Now press #a to execute the macro. Use a quantifier to execute it multiple times.
Type :help q to find out more about recording macro's.

Resources