How do I reformat long (doc) comments in my code? Hitting "reformat" doesn't work. For example when I have this in my code:
/**
* Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin porta ac urna quis sagittis. Nam risus leo, ultricies
* id ante sed, bibendum rutrum diam.
* Suspendisse viverra dui et ligula aliquet, sit amet mattis magna consequat. Morbi venenatis tempus mattis.
* Praesent mollis quam non turpis laoreet placerat.
*/
How do I turn it into this?
/**
* Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin porta ac urna quis sagittis. Nam risus leo, ultricies
* id ante sed, bibendum rutrum diam. Suspendisse viverra dui et ligula aliquet, sit amet mattis magna consequat. Morbi
* venenatis tempus mattis. Praesent mollis quam non turpis laoreet placerat.
*/
Such functionality is not currently available in PhpStorm.
But you may try Wrap to Column plugin -- it may do OK for you (seems to work -- based on very quick test).
Related tickets:
http://youtrack.jetbrains.com/issue/WI-374
http://youtrack.jetbrains.com/issue/WI-3713
http://youtrack.jetbrains.com/issue/WI-13469
http://youtrack.jetbrains.com/issue/WI-18264
Related
I have a pandas dataframe with multiple columns. I am working on a specific column named "Text_annotated" whose structure is like :
Text_annotated
<html> Lorem ipsum dolor sit amet, <phrase>consectetur adipiscing elit</phrase>, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. <phrase>Ut enim ad minim veniam</phrase>, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</html>
<html> Faucibus vitae aliquet nec ullamcorper sit amet risus nullam. Pellentesque sit amet porttitor eget dolor morbi. <phrase>Tincidunt praesent semper feugiat nibh sed pulvinar. Lobortis elementum nibh tellus molestie nunc non blandit.</phrase> Tellus at urna condimentum mattis.</html>
<html>Pulvinar etiam non quam lacus. Amet purus gravida quis blandit. Scelerisque eu ultrices vitae auctor eu augue ut. Tincidunt lobortis feugiat vivamus at augue eget arcu dictum varius. Pellentesque adipiscing commodo elit at imperdiet.</html>
and I want to extract only the text between the <phrase></phrase> tags. For this reason, I decided to use PyQuery. So far I have tried
text_phrases= df['Text_annotated'].tolist()
doc = pq(f"{text_phrases}")
phrase_macro = doc.find("phrase").text()
which returns a pyquery.pyquery.PyQuery where each "newline" contains only one result e.g.
consectetur adipiscing elit
Ut enim ad minim veniam
Tincidunt praesent semper feugiat nibh sed pulvinar. Lobortis elementum nibh tellus molestie nunc non blandit.
Thus, my question is whether it's possible to group the results for each row in the df separated by a comma e.g.
consectetur adipiscing elit, Ut enim ad minim veniam
Tincidunt praesent semper feugiat nibh sed pulvinar. Lobortis elementum nibh tellus molestie nunc non blandit.
(I have also tried to iterate over the objects phrases_res = [h.text() for h in doc('phrase').items()] which didn't work)
Any help/suggestion is much appreciated.
PS. Each row is just wrapped with a <html> tag, without any other particular structure.
EDIT: Tried also to "separate" somehow according to the html tag, but returned the previous result.
rows = doc('html')
for row in rows.text():
phrase_res = doc.find("phrase").text()
new_df['Phrases_res'] = phrase_res
new_df.head(5)
You can use pandas.Series.str.findall with a regex expression to return a list of all the strings between two delimiters.
Try this :
import pandas as pd
pd.options.display.max_colwidth = None
data = ['<html> Lorem ipsum dolor sit amet, <phrase>consectetur adipiscing elit</phrase>, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. <phrase>Ut enim ad minim veniam</phrase>, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</html>',
'<html> Faucibus vitae aliquet nec ullamcorper sit amet risus nullam. Pellentesque sit amet porttitor eget dolor morbi. <phrase>Tincidunt praesent semper feugiat nibh sed pulvinar. Lobortis elementum nibh tellus molestie nunc non blandit.</phrase> Tellus at urna condimentum mattis.</html>',
'<html>Pulvinar etiam non quam lacus. Amet purus gravida quis blandit. Scelerisque eu ultrices vitae auctor eu augue ut. Tincidunt lobortis feugiat vivamus at augue eget arcu dictum varius. Pellentesque adipiscing commodo elit at imperdiet.</html>']
df = pd.DataFrame(data, columns=['Text_annotated'])
df['Phrases'] = df['Text_annotated'].str.findall(r"<phrase>(.*?)</phrase>")
>>> display(df)
I'm writing a pdf report in RMarkdown and want to float_left a kable with a caption. This works without a caption:
---
title: "test2"
output: pdf_document
header-includes:
- \usepackage{wrapfig}
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
options(knitr.table.format="latex")
```{r, echo=FALSE}
library(knitr)
library(kableExtra)
kbl(head(cars), booktabs=T) %>%
kable_styling(latex_options = "striped", position = "float_left")
But adding caption="A Caption" to the kbl line, as in
kbl(head(cars), caption="A Caption", booktabs=T) %>%
throws this error:
! Extra }, or forgotten \endgroup.
\endwraptable ...kip \egroup \box \z# \fi \egroup
\WF#floatstyhook \def \wid...
l.164 \end{wraptable}
Error: LaTeX failed to compile test2.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See test2.log for more info.
Execution halted
I've searched SO for what I'd think would be a frequent situation, but have found nothing. It must be something simple I'm missing. Help please.
There is a solution here (although the caption moves to the bottom): https://github.com/haozhu233/kableExtra/issues/221#issuecomment-400473530
Following this solution, you could try this .Rmd file:
---
title: "test2"
output: pdf_document
header-includes:
- \usepackage{wrapfig}
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
options(knitr.table.format="latex")
```
Lorem ipsum dolor sit amet, consecteturadipiscing elit. Cras sit amet mauris inex ultricies elementum vel rutrum dolor.Phasellus tempor convallis dui, in hendreritmauris placerat scelerisque. Maecenas a ac-cumsan enim, a maximus velit. Pellentesquein risus eget est faucibus convallis nec atnulla. Phasellus nec lacinia justo. Morbifermentum, orci id varius accumsan, nibhneque porttitor ipsum, consectetur luctusrisus arcu ac ex. Aenean a luctus augue. Suspendisse et auctor nisl. Suspendisse cursus ultrices quam nonvulputate. Phasellus et pharetra neque, vel feugiat erat. Sed feugiat elit at mauris commodo consequat. Sedcongue lectus id mattis hendrerit. Mauris turpis nisl, congue eget velit sed, imperdiet convallis magna. Namaccumsan urna risus, non feugiat odio vehicula eget.
```{r, echo=FALSE}
library(knitr)
library(kableExtra)
library(xtable)
xtable2kable <- function(x) {
out <- capture.output(print(x, table.placement = NULL))[-(1:2)]
out <- paste(out, collapse = "\n")
structure(out, format = "latex", class = "knitr_kable")
}
xtable(head(cars), booktabs=T, caption="A Caption") %>%
xtable2kable() %>%
kable_styling(latex_options = "striped", position = "float_left")
```
Lorem ipsum dolor sit amet, consecteturadipiscing elit. Cras sit amet mauris inex ultricies elementum vel rutrum dolor.Phasellus tempor convallis dui, in hendreritmauris placerat scelerisque. Maecenas a ac-cumsan enim, a maximus velit. Pellentesquein risus eget est faucibus convallis nec atnulla. Phasellus nec lacinia justo. Morbifermentum, orci id varius accumsan, nibhneque porttitor ipsum, consectetur luctusrisus arcu ac ex. Aenean a luctus augue. Suspendisse et auctor nisl. Suspendisse cursus ultrices quam nonvulputate. Phasellus et pharetra neque, vel feugiat erat. Sed feugiat elit at mauris commodo consequat. Sedcongue lectus id mattis hendrerit. Mauris turpis nisl, congue eget velit sed, imperdiet convallis magna. Namaccumsan urna risus, non feugiat odio vehicula eget.
Lorem ipsum dolor sit amet, consecteturadipiscing elit. Cras sit amet mauris inex ultricies elementum vel rutrum dolor.Phasellus tempor convallis dui, in hendreritmauris placerat scelerisque. Maecenas a ac-cumsan enim, a maximus velit. Pellentesquein risus eget est faucibus convallis nec atnulla. Phasellus nec lacinia justo. Morbifermentum, orci id varius accumsan, nibhneque porttitor ipsum, consectetur luctusrisus arcu ac ex. Aenean a luctus augue. Suspendisse et auctor nisl. Suspendisse cursus ultrices quam nonvulputate. Phasellus et pharetra neque, vel feugiat erat. Sed feugiat elit at mauris commodo consequat. Sedcongue lectus id mattis hendrerit. Mauris turpis nisl, congue eget velit sed, imperdiet convallis magna. Namaccumsan urna risus, non feugiat odio vehicula eget.
Output:
I have a groff document, however, when I set the trap to create a footer, groff puts one word after the specified height, then executes the macro for the trap. I am compilinig the document with groff -Tpdf -P-pletter ex.groff > ex.pdf.
ex.groff:
.de foot
. bp
..
.wh -1i foot
.ls 2
.nh
.ad l
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
In pulvinar, ex id ultricies tincidunt, ligula neque hendrerit velit, id feugiat enim nisl eu justo.
In bibendum elementum auctor.
Fusce dapibus sed nulla in malesuada.
Ut vehicula ultrices nibh, at iaculis est consectetur vitae.
Phasellus condimentum est in elit ultrices mattis.
Mauris orci sem, dictum eleifend augue vitae, fermentum convallis nunc.
In semper vitae nunc a congue.
Pellentesque pretium risus vitae turpis mollis, a blandit lacus vestibulum.
Vivamus congue urna mauris, ac viverra ipsum tristique id.
Maecenas mauris massa, ullamcorper eu fringilla consequat, molestie ac nunc.
Etiam luctus tortor id odio fringilla, eu eleifend leo imperdiet.
.br
Integer venenatis et mi dignissim dictum.
Duis rutrum tortor lectus, eget pulvinar risus viverra id.
Vivamus vel vestibulum neque, in posuere libero.
Praesent eu erat ut ligula consequat consectetur sed nec magna.
Pellentesque vitae rhoncus felis.
Suspendisse potenti.
Nullam in sodales nisi.
Nulla vitae tempus sem, non laoreet felis.
.br
Fusce velit metus, condimentum non ultricies facilisis, dignissim eu diam.
Donec lorem ante, pulvinar et congue non, iaculis ac leo.
Nam sit amet risus dui.
Mauris lorem nunc, facilisis non odio dapibus, gravida posuere leo.
Quisque pellentesque tincidunt dolor sed eleifend.
Nam eget augue feugiat, tincidunt orci et, tempor quam.
Suspendisse purus mi, mollis quis porta quis, tincidunt vel odio.
Pellentesque nisl sapien, posuere sed accumsan eget, elementum vel est.
Maecenas cursus neque quis arcu varius, at efficitur dui dictum.
.br
Etiam semper ultrices ipsum, eget gravida risus condimentum vel.
Suspendisse sed tincidunt lectus.
Suspendisse faucibus gravida lorem, vel volutpat eros hendrerit nec.
Vestibulum ac leo eget metus sollicitudin rhoncus.
Fusce venenatis ligula a sodales varius.
Etiam mauris nisi, ultricies eu ex quis, vehicula facilisis nulla.
Pellentesque eu arcu nec urna tempor fringilla.
Sed consectetur, leo at convallis finibus, nunc mi feugiat dolor, a tincidunt tortor ipsum vitae sem.
Vestibulum tincidunt, nisl vel hendrerit consequat, leo felis rutrum tellus, quis tempor odio leo in lectus.
Donec placerat tempor turpis nec efficitur.
Donec quis erat a augue tempor lacinia sit amet ac felis.
Donec a dui ut diam tempus cursus.
Sed auctor, lorem sed interdum blandit, erat dui tristique dolor, vitae condimentum lorem dui ac augue.
.br
Phasellus et dignissim lacus.
Vestibulum a dolor sodales est bibendum sodales.
Nulla gravida erat lacus, in placerat sapien consequat id.
Donec vitae pulvinar neque.
Etiam a semper augue.
Phasellus sed justo id velit imperdiet finibus.
Nam eget vulputate orci, ac congue nunc.
Pellentesque sollicitudin, nulla quis luctus pulvinar, velit ex feugiat leo, sed euismod ante odio at est.
Duis velit sapien, ornare vel vulputate in, consectetur non neque.
Curabitur non libero at magna venenatis cursus et vel urna.
.br
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
In pulvinar, ex id ultricies tincidunt, ligula neque hendrerit velit, id feugiat enim nisl eu justo.
In bibendum elementum auctor.
Fusce dapibus sed nulla in malesuada.
Ut vehicula ultrices nibh, at iaculis est consectetur vitae.
Phasellus condimentum est in elit ultrices mattis.
Mauris orci sem, dictum eleifend augue vitae, fermentum convallis nunc.
In semper vitae nunc a congue.
Pellentesque pretium risus vitae turpis mollis, a blandit lacus vestibulum.
Vivamus congue urna mauris, ac viverra ipsum tristique id.
Maecenas mauris massa, ullamcorper eu fringilla consequat, molestie ac nunc.
Etiam luctus tortor id odio fringilla, eu eleifend leo imperdiet.
which produces the undesired word right after the trap height (the word on the final line should be on the next page)
How can I make it so this word appears on the next page, instead of right where the trap should be?
I dont have the reference to hand, but from my notes, in the table listing the basic troff commands we have
.bp +-N N=1 Bbv new page. number of next page
where Bbv are a set of flags including this: b will cause line break unless use ' instead of . so the answer is to define your macro to call 'bp instead of .bp.
.de foot
' bp
..
The online groff doc briefly says about requests:
A request line begins with a control character, which is either a
single quote (', the no-break control character) or a period (., the normal control character).
and for bp has an example using 'bp.
I want to load a whole html file as testdata with liquibase. So far I've used the approach with loading testdata from csv file, but it is not designed to handle huge html's.
Is there a way to achieve it?
Here is an example to make it clear:
I have a table named Movie. The fields are: id, title, description. In a databaseChangeLog section I point to a file where I store the testdata:
<loadData encoding="UTF-8"
file="config/liquibase/testdata/movie.csv"
separator=";"
tableName="movie"/>
The content is as follows:
id;title;description
1;Titanic;great movie
2;Forrest Gump;another great movie
Now I want to change the description to something that is closer to the real usecase. Lets say this HTML:
<div id="lipsum">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce porta pulvinar lacus eget egestas. Ut quis efficitur turpis. Nunc tincidunt turpis lorem, eget vestibulum nisi sodales at. Quisque in tortor et sapien ornare venenatis. Integer pulvinar nec ipsum malesuada porta. Sed massa metus, condimentum non varius ornare, sollicitudin at dui. Praesent porta, ante et interdum convallis, tellus augue tempus nisl, sit amet mollis augue nisl vel metus.
</p>
<p>
Nam quis libero rhoncus, facilisis magna ut, bibendum urna. Nullam sit amet volutpat turpis. Praesent eget aliquet orci. Duis dignissim tellus erat, eget fermentum augue dapibus sed. Quisque vitae est ipsum. Quisque sit amet libero eget nisi faucibus maximus vel a sem. Proin maximus neque arcu, sit amet eleifend dolor ornare at. Suspendisse laoreet lobortis tellus sed consequat. Nunc commodo ligula eget neque porta consectetur. Mauris sagittis elit in sodales luctus.
</p>
</div>
The content won't fit into the csv file. I could delete all the newlines, but it makes the file unmaintainable.
loadData has a column attribute which in turn has a valueClobFile attribute where you could put in a path to a (html) file.
Checkout these two files in the liquibase integration tests that show a use of this:
batchInsert.changelog.xml
batchInsert.csv
How could I align the RTL text to justify on react-native? As the react-native website says we could set align of text to 'auto', 'left', 'right', 'center', 'justify' but the justify one is not working on RTL text.
text justify not support in react native android native. but there is a trick that you justify your text with WebView Component...
here is a sample code:
<WebView
source={{
html:
"<style>p{text-align:justify}</style>" +
"<p>" +
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus commodo tortor ut ipsum pharetra sodales. Praesent sed diam non lacus convallis dapibus. Sed vulputate erat risus, ac hendrerit eros egestas id. Etiam pellentesque auctor ipsum, non cursus nisi gravida sed. Ut eget pretium risus. Curabitur a lectus odio. Etiam felis urna, pharetra ut odio in, tristique suscipit tortor. Cras vitae risus odio. Etiam a leo elit. Duis molestie fermentum mi vitae pretium. Morbi luctus semper quam, et suscipit nisi convallis dictum. Fusce sit amet est dapibus, interdum ante non, lacinia metus. Donec at nulla non ante consectetur vulputate. Cras tristique porttitor ligula quis posuere. Integer nec laoreet felis, at tempor leo. Ut et convallis quam." +
"</p>"
}}
/>
if you want call your body texts from your server compile to html and use your source in it (this is not a good but only way)