Included files after list not rendered correctly - textmate2

main.asc:
== Items
include::foo.asc[]
include::bar.asc[]
foo.asc
=== Foo Title
==== List of things
* thing one
* thing two
bar.asc
=== Bar Title
this is a summary of bar
When main.asc is rendered, the following text is displayed:
Items
Foo Title
thing one
thing two === Bar Title
this is a summary of bar
I've also tried adding a simple paragraph at end of foo.asc after the list to see if that will fix the problem--it didn't.
Is there a way to fix this?

Adding a line between the two include statements seems to fix the issue:
== Items
include::foo.asc[]
include::bar.asc[]

You should always end all asciidoc files with a blank line, I actually keep a comment at the end of all my files to remember me:
////
Always end a file with a blank line to avoid include problems.
////
When you don't have a blank line the second file is included at end of previews line, and the result will be:
thing two === Bar Title

Related

insert GlyphProperty.null in shouldGenerateGlyphs causes cursor misplacement problem

I am hiding the character * by inserting GlyphProperty.null then calling setGlyphs(_:properties:characterIndexes:font:forGlyphRange:) inside layoutManager(_:shouldGenerateGlyphs:properties:characterIndexes:font:forGlyphRange:) as described in the answer in https://stackoverflow.com/a/57697139/9568961, it works but after a certain sequence of text editing, the cursor starts to misplace, as shown in the gif https://github.com/dzAtZJU/Demos/blob/master/cursor_misplace.GIF?raw=true
GIF Description: When the second line becomes qq, I try to move the cursor to the end of first line, but it move directly to the beginning. I then try to delete characters, then the cursor move to the end correctly.
The sample project is here https://github.com/dzAtZJU/HideText.
Is it a bug? Have anyone run into this? How can I work around this?
This is a year-old question, but for anyone struggling with the same problem, here's a solution.
My Markdown-like parser knows the ranges for both the line on which the cursor is now, and where it was previously. I'm calling hideAndShowMarkup whenever text view selection changes.
You need to invalidate current glyphs for both of the ranges, and then redraw them synchronously before updating insertion point. The most crucial step is invalidating layout for the range where you want to show Markdown symbols. Without that, your caret gets drawn into the wrong position.
Code is in Objective C, but should be easy to implement in Swift, too.
-(void)hideAndShowMarkup {
// Just for reference
Line* line = currentLine;
Line* prevLine = previouslySelectedLine;
[self.layoutManager invalidateGlyphsForCharacterRange:line.range changeInLength:0 actualCharacterRange:nil];
[self.layoutManager invalidateGlyphsForCharacterRange:prevLine.range changeInLength:0 actualCharacterRange:nil];
[self.layoutManager invalidateLayoutForCharacterRange:line.range actualCharacterRange:nil];
if (NSGraphicsContext.currentContext) {
[self.layoutManager drawGlyphsForGlyphRange:line.range atPoint:self.frame.origin];
[self.layoutManager drawGlyphsForGlyphRange:prevLine.range atPoint:self.frame.origin];
}
[self updateInsertionPointStateAndRestartTimer:NO];
}

Selenium's .text just giving blank lines

I've got this:
....
events = driver.find_elements_by_class_name("textblock")
for event in events:
content = event.text
print(content)
print(events)
This is the element, there are multiple. Each with different text:
<div class="textblock">example text</div>
Here's the output:
# one blank line for every item in list below...
# items below have been striped
[<selenium.webdriver.firefox.webelement.FirefoxWebElement (session="", element="")>, <selenium.webdriver.firefox.webelement.FirefoxWebElement (session="", element="")> # and so on...
As you can see, instead of the text inside the div, I'm getting blank lines. Why is that?
Selenium will only return visible text. So, if this div is hidden in any way, or obstructed by another element, it will return an empty string because it is not visible. If you still need the text even if it's not visible, use javascript:
events = driver.find_elements_by_class_name("textblock")
for event in events:
content = driver.execute_script('return arguments[0].textContent;', event)
print(content)
print(events)
As per the HTML you have shared your code block looks good to me. However I would suggest you to get a bit granular and instead of using .text method we can use get_attribute("innerHTML") method as follows :
....
events = driver.find_elements_by_class_name("textblock")
for event in events:
content = event.get_attribute("innerHTML")
print(content)
print(events)

Python Selenium, the text of the next element

I can get the text of the first element. But I do not know how to go through the entire list and get the text of each element. Here is the tree from the site:
Screenshot
So I get the text of the first element:
driver.find_element_by_xpath("//a[#my-peer-link='participant.user_id']").click()
print(driver.find_element_by_xpath("//span[#ng-bind=\"'#' + user.username\"]").text)
In each
div class="md_modal_list_peer_wrap clearfix" ng-repeat="participant in
chatFull.participants.participants"
is contained
div class="md_modal_list_peer_name"
which contains
a class="md_modal_list_peer_name"
my-peer-link="participant.user_id">Олег
which you need to press. That is, execute:
driver.find_element_by_xpath("//a[#my-peer-link='participant.user_id']").click()
After that, a new window opens, from which I get the text of the element:
driver.find_element_by_xpath("//span[#ng-bind=\"'#' + user.username\"]").text
But there are several of these elements and I need to get the text with everyone:
div class="md_modal_list_peer_wrap clearfix" ng-repeat="participant in
chatFull.participants.participants"
How to do it?
Vladimir, I haven't done a careful analysis of this problem; however, could it be as simple as this?
Rather than using
driver.find_element_by_xpath("//span[#ng-bind=\"'#' + user.username\"]").text
could you use:
for span in driver.find_elements_by_xpath("//span[#ng-bind=\"'#' + user.username\"]"):
span.text
(Notice plural in `find_elements_by_xpath'.)
You'll need to click each element and store the text in a list:
So first use
elements_to_click = driver.find_elements_by_xpath("//a[#my-peer-link='participant.user_id']"
This will return a list of elements
Loop through those elements by
clicking on element
switch to the new window (When a new WindowHandle was created, otherwise skip this step.)
get the text via
driver.find_element_by_xpath("//span[#ng-bind=\"'#' + user.username\"]").text
store it in a list
close window (When a new WindowHandle is created, otherwise skip this step.)
switch to previous window

JTextPane, second word must not go to new line when typing and exceeding width

I'm using JTextPane because I need to markup text.
When typing into the JtextPane the second word always goes to new line. Then also when making the second word longer (after it went to a new line) the scroll bar appears and the JTextPane resizes. If I start typing in a new row then second word in that line does not go to a new line (as long the second word does not exceed width)
I tried adding a blank string that is very long in the first line and seems to do the trick, but this blank line is not really what I want to have.
Also tried adding it to after the text but it gives more problems
Is there something else that I can do to make the text only go to new line when I press enter? I can do it without a blank string using jtextarea, but then I can't markup text as I type.
I found the answer:
JTextPane textPane = new JTextPane()
{
public boolean getScrollableTracksViewportWidth()
{
return getUI().getPreferredSize(this).width
<= getParent().getSize().width;
}
};
We can overite the getScrollableTracksViewportWidth method to have a no wrapping text pane.
Website for more info: Here

Whenever I type colon in insert mode it moves my text to the very beginning of line

Whenever I type a : (colon) it moves all the text on the current line to the beginning of the line, ignoring spaces and tabs.
So if I type
var combo = new Ext.form.ComboBox({
typeAhead //I'm about to type a colon, but right now it looks fine
})
Then I type the colon it moves the text and it now looks like
var combo = new Ext.form.ComboBox({
typeAhead: //text is no longer indented
})
This is a javascript file, so that might be causing the problem?
How can I stop my text from being moved to the beginning of the line when I type a colon?
Adding a colon to the end of a token is causing vim to interpret it as a jump label for C-indenting purposes. :set cino+=L0 should cause it to stay in the current column.
Also, doesn't the JSON syntax allow you to quote the thing that precedes the colon? That should prevent vim from thinking it's a label too.
var combo = new Ext.form.ComboBox({
"typeAhead": "foo" // this isn't a jump label
});

Resources