How to add line breaks to Redmine markdown in code highlighting? - formatting

The Redmine textile formatting guide directs us to use code highlighting like so:
<pre><code class="ruby">
Place your code here.
</code></pre>
And while line breaks are preserved within <pre> tags, once I add the <code class="python">, it removes all line breaks and places all the text on a single line. And of course, hacks like (which answered this question) or html tags don't work because it's still wrapped inside <pre>.
I've tried wrapping each individual line with <code></code> all within one <pre></pre>, but that didn't work. I've tried adding double spaces to the end of each line, and additional new lines in between but to no avail.
And while the Redmine guide above says code highlighting relies on Rouge, my version of Redmine uses CodeRay, whose website examples handle line breaks perfectly.
Thanks in advance!

Things are working ok for me. See my screenshots. Perhaps your theme is affecting that.
I'm using Abacus office 1.3.4 theme on Redmine v3.2.
Could any plugins that you have installed be causing that?

Related

VSCode prettier/vue formatting settings don't work properly

I have read about 10-15 other answers now and none of the solutions (which are all the same minus 3 or 4) have worked for me. I am using Prettier and Vetur and I have the ESLint extension in VSCode installed as well. I have looked over the settings at least 10 times in the past 3 days trying to touch everything, close/open VSC and save to format, check if the problem persists, and continue doing this with each setting one-by-one trying to eliminate the suspects. I am here as a last resort out of desperation to be able to save my components without breaking my html tags and separating code into illegible BS.
My expected code formatting looks like this:
<button
class="btn btn-success"
#click="sellStock"
:disabled="insufficientFunds || quantity <= 0 || !Number.isInteger(quantity)"
>{{ insufficientQuantity ? "Not enough Stocks" : "Sell" }}</button>
and my formatter is causing the " at the end of the line after "...isInteger(quantity)" to be line-broken which breaks my entire component's syntax/major linter errors appear (obviously).
<button
class="btn btn-success"
#click="sellStock"
:disabled="
insufficientFunds || quantity <= 0 || !Number.isInteger(quantity)
"
>
{{ insufficientQuantity ? "Not enough Stocks" : "Sell" }}
</button>
As you can see, even the line breaks are uneven and make ZERO sense formatter-wise...I've never seen it do this before. This is next-level annoying Vue/Vetur/Prettier/VScode formatting bugs now and I'm quite stumped as to why it's suddenly acting up this week.
I have tried changing word-wrap-length and prettier lengths and indentations, font size and appearance of the mini map...nothing seems to make this madness stop, not even turning of html formatting period. It also formats some of my other ".vue" components into multiple lines when I don't want it to, but it isn't breaking the syntax/html tags as it is here. I have made the word-wrap/line-length 200+ everywhere that it's listed as a settings and it continues to break my code.
Any ideas?
Only advice I can give is stop using Prettier. Trying to make it work with ESlint and Vetur was always pain. Then I found this question (and self answer) here on SO which recommends dropping Prettier and using ESlint not just for linting but also for formatting (needs version >= 6). I'm happy as clam now...
I've been struggling with a similar problem with VSCode's formatting. I also have Prettier, ESLint and Vetur extensions installed. But my code formatting rules were somehow different from my co-worker's (they are using WebStorm by the way).
In my case, the problem was solved by:
Turning off all the Vetur formatters and disabling all formatting capabilities of Vetur.
Enabled ESLint as the formatter.
This seems to have allowed the Prettier extension to look at .eslintrc.js, which the Prettier plugin is setup.
I suggest that you look in on the Prettier extension logs to debug your problem.
On the bottom right corner of VSCode's window, you will see the Prettier extension indicator. Click on this and you can see the logs.
Once the logs are shown, you can see where the extension is getting the Prettier configs from, or where the Prettier module is being imported from.
What helped me with this situation, I went into Vetur's extension settings inside VSCode Vetur > Format > Default Formatter: HTML and selected js-beautify-html.
I just had this problem and resolved it.
The issue I had was that my html in the .vue file was malformed (Specifically I had a closing tag which shouldn't have been there).
I was relying on it formatting on save, and when that didn't work I tried manually selecting "format document with prettier" which did nothing.
It was only when I looked in the output window (Which I should have done immediately) that I saw that it was complaining about the misplaced closing div tag.
It's a silly oversight, but easily made.
What fixed it for me was to actually turn on Eslint to work as a formatter in settings.
Due to logs, I just needed to install the prettier dependency, so:
yarn install
or, if you do not have it already, add it:
yarn add prettier
this fixed my problem.

Custom snippets.json with Emmet - was working now it doesn't

I created a custom snippets.json for emmet that added snippets for ExpressionEngine code. This was working great for several weeks. Then one day without having made any changes to the file it has stopped working. I have uninstalled/installed emmet several times, have reset paths for extensions_path and even tried using prior working versions of the file but all to no avail.
I've got the file sitting in dropbox so that I can use it on my laptop and desktop. Has stopped working on both computers. Am completely flummoxed about why this mysteriously stopped working when there was no change between one day and the next.
Any thoughts on how to get this working?
This file is not a valid JSON since it contains comments.
In previous versions Emmet simply eval’ed configs to make such things as comments work but I had to switch to JSON parser to make Emmet CSP-compliant (required by many browser-based editors).

IntelliJ wrapping comments in Javascript

Is it possible to wrap long comment lines in IntelliJ in javascript files? I have turned on line wrapping as shown in the settings below, but when I do a code reformat, it doesn't wrap the line.
It's not supported yet on code reformatting, added a new feature request, please vote.
I'm using IntelliJ 14 on a Mac, which has a Fill Paragraph command. Access it via the awesome universal Command-Shift-A action search feature. Works like a charm!

When using pdfpages in LaTeX, how to avoid page breaks before the first page ?

I am creating a large LaTeX document, and my appendix has reproductions of several booklets that I have as PDFs. I am trying to create a section header and then include the pages at a slightly lower scale. For example:
\section{Booklet about Yada Yada Yada}
\includepdf[pages={-}, frame=true, scale=0.8]{booklet_yadayada.pdf}
However, pdfpagex does two annoying things. First, it devotes one output document page for included document page. I can live with that as I am using 80% scale. The main problem, however, is that the first page is also a new page, so I have a page with just a section title, and then a separate page with the booklet.
Is there some way to get pdfpages to be a little smarter here?
\includepdf uses \includegraphics internally, so something like
\section{Foo}
\fbox{\includegraphics[page=1,scale=0.8]{foo.pdf}}
would include the page without starting a new one, although it only does one page at a time.
For me the following worked just fine:
\includepdf[pages=1,pagecommand=\section{Section Heading}]{testpdf}
\includepdf[pages=2-,pagecommand={}]{testpdf}
I tried this solution too, but \includepdf keeps the advantage of outputting the file over the margin (the output is centered from the edges of the page).
So I openned pdfpages.sty, and I searched for \newpage command. I deleted the first occurance (line 326), just to try, and after saving then compiling again, there were no page break anymore.
Use the minipage environement :
\chapter*{Sujet du stage}
%\fbox{
\begin{minipage}{\textwidth}
\includepdf[scale=0.8]{../sujet-stage/main.pdf}
\end{minipage}
It doesn't add any extra page and it works with includepdf.
Thanks for all the answers - I couldn't for the life of me figure out what logic \includepdf uses to insert blank pages; the trick with including the first page via \includegraphics solved most (but not all) of those problems; so here are some notes:
First, out of curiosity, I have also tried to use only \includepdf, but split in two parts:
\includepdf[pages=1]{MYINCLDOC.pdf}
\includepdf[pages=2-last]{MYINCLDOC.pdf}
... unfortunately, this has the same problem as the question in OP.
Since #WASE's answer, there are now multiple \newpages in the source (pdfpages.sty). I tried reading the source, but I found it quite difficult; so I tried temporarily setting \newpage to \relax only for \includepdf - and that puts all pages in the document on top of each other; so probably not a good idea to get rid of \newpage blindly.
Just \includegraphics[page=1,scale=0.8]{foo.pdf} works - but (as #WASE also note) it is aligned at the top-left corner of the page body, which is to say inside the margins; for a full page we'd want the pdf inclusion overlaid over the whole page, margins included.
This page: graphics - How do I add an image in the upper, left-hand corner using TikZ and graphicx - TeX - LaTeX points to several possibilities for positioning on page over the margins; but for me, the best solution for a full page PDF inclusion is to use package tikz to center it to the page:
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.center) {\includegraphics[page=1]{MYINCLDOC.pdf}};
\end{tikzpicture}
\includepdf[pages=2-last]{MYINCLDOC.pdf}
After this is done, as a bonus, I have also experienced:
Proper targets of PDF bookmarks (going to the right page when clicked)
If you use package pax, the data seems to be included also for the \includegraphics standalone first page, so no difference there
If you have a twoside document - pdfpages, with the above split of the first page in \includegraphics, will now (seemingly) correctly insert the equivalent of \cleardoublepages between pdfs that are included back to back (so I don't have to insert such a command manually).
Hope this helps someone,
Cheers!
I'm a little late, but the following solution worked for me:
\includepdf[pages={-},angle=90, scale=0.7]{lorem-ipsum.pdf}
All pages are imported, scaled and rotated by 90 degrees.
Works with Texmaker 5.0.4

Objective-c code formatter site to create html that can be embedded into a blog

I'm looking for site similar to http://www.manoli.net/csharpformat/ that allows one to put in c# code snippet and it formats the html to post into your blog with a CSS file.
I need one that actually does this for Objective-C.
You want the GeSHi (Generic Syntax Highlighter) library. It's is excellent, has dozens of languages (including Objective-C, with the ability to automatically linkify classes/protocols to the documentation), and support for many popular CMSs (Django, WordPress, Drupal, Joomla, Mambo, etc).
If you'd like to see it in action, you can check out nearly any wiki page on our local CocoaHeads website. For example: http://cocoaheads.byu.edu/wiki/different-nslog
Assuming you're on a Mac, copying code from Xcode will keep the syntax coloring. Any WYSIWYG blog editor should support that.
In case your blog software isn't WYSIWYG, you can paste into TextEdit and save as HTML. It outputs pretty crappy HTML considering it's just highlighted source code, but it's nonetheless compliant HTML.
Other than that, I don't know of an online service for that.
I use pygments (python) to generate syntax highlight for source code examples embedded in blog.
If your entry text is just the source code it will work the same for what you are after, I tested it to highlight Objective-C as well.
I actually use markdown syntax to type plain text blog post in a file and I copy plain text code examples. Then I run the file via markdown processor, which includes pygments for highlight and store it into a file.
It's as simple as:
include markdown
html = markdown.markdown(text,['codehilite'])
See simple script at the link which just takes file name of your plain text file and creates html file.
Then I can copy/paste the code.
You have to include link or copy the css as well to get the syntax highligh but it's easy.
I do this for blogger, see example how to use markdown with pygments to do syntax highlight.