Code Monkey home page Code Monkey logo

Comments (17)

gpoore avatar gpoore commented on July 19, 2024 10

The breaklines option now works for \mintinline.

from minted.

gpoore avatar gpoore commented on July 19, 2024 7

@gembez The default breaklines only inserts breaks at spaces. If you don't have spaces, you need to use breakanywhere, or specify particular characters to break before/after with breakbefore and breakafter. Details are in the documentation.

from minted.

gpoore avatar gpoore commented on July 19, 2024 6

@gembez For all inline content: \setmintedinline{breaklines}. For individual commands: \mintinline[breaklines]{<lang>}{<code>}.

from minted.

gpoore avatar gpoore commented on July 19, 2024 6

@benkuly I was forgetting that all of the special breaklines options like breakbefore and breakafter and breakanywhere don't work with \mintinline. Here's a patch you can add to your preamble that should get it working. You will want something like \mintinline[breaklines, breakafter=-]{xml}{spring-boot-starter-test}. I will probably need to refine this a little before releasing it in a future version of minted.

\usepackage{minted}
\makeatletter
\renewcommand{\minted@inputpyg}{%
  \expandafter\let\expandafter\minted@PYGstyle%
    \csname PYG\minted@get@opt{style}{default}\endcsname
  \VerbatimPygments{\PYG}{\minted@PYGstyle}%
  \ifthenelse{\boolean{minted@isinline}}%
   {\ifthenelse{\equal{\minted@get@opt{breaklines}{false}}{true}}%
    {\let\FV@BeginVBox\relax
     \let\FV@EndVBox\relax
     \def\FV@BProcessLine##1{%
       \FancyVerbFormatLine{%
         \FV@BreakByTokenAnywhereHook
         \FancyVerbFormatText{\FancyVerbBreakStart##1\FancyVerbBreakStop}}}%
     \minted@inputpyg@inline}%
    {\minted@inputpyg@inline}}%
   {\minted@inputpyg@block}%
}
\makeatother

You can change the symbol that appears at the break using breakaftersymbolpre.

from minted.

zhanwenchen avatar zhanwenchen commented on July 19, 2024 4

By accident, I discovered a strange combination that worked. Up top, I declared \setmintedinline{breaklines} but each time specify \mintinline[breakanywhere]{...}{...}. A self-contained example is below:

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{minted}
\usemintedstyle{borland}

\setmintedinline{breaklines} % necessary for breakanywhere to work later on.

\title{EECE5354 Computer Vision: Assignment 1}
\author{Zhanwen Chen}
\date{January 27, 2019}

\begin{document}

\maketitle

\section{Introduction}

This assignment requires implementation of three image processing functions: separation filter with a Gaussian kernel, and two more with my choosing. In addition, other deliverables include a function to limit all image processing functions to only process a sub-region specified by a rectangle, and an example video output with specific operations.

\vspace{5mm}

In my solution, I first refactored the assignment starter script, \mintinline[breakanywhere]{python}{testcv_mt_vid.py}, to use object-oriented approach where I replaced with state attributes all global variables that the program modifies during running.

\section{Implementation of Separation Filter}


1. \mintinline[breakanywhere]{python}{sepFilter2D()} with a Gaussian Kernel that you generate using \mintinline[breakanywhere]{python}{getGaussianKernel()}. (Note that you can get the same results using the module called \mintinline{python}{GaussianBlur()}. But I want you to use \mintinline{python}{sepFilter2D} with a Gaussian Kernel so that you learn how to apply an arbitrary separable filter to an image.)

\end{document}

from minted.

gembez avatar gembez commented on July 19, 2024 2

The following dependencies are used by every application: \mintinline[breaklines]{xml}{spring-boot-starter-web} and \mintinline[breaklines]{xml}{spring-boot-starter-test}.

image

doesn't seem to work for me. I get a Overfull \hbox (40.09329pt too wide) in paragraphwarning.

Best & thanks!

from minted.

gpoore avatar gpoore commented on July 19, 2024 1

@arch-linux-tux The code does usually work, but your particular example is failing due to TeX's hyphenation system. minted uses fvextra internally for the line breaking. The break itself uses \discretionary, which involves TeX's hyphenation system. By default, hyphenation won't work for such a long string of text with only a single possible hyphenation point (the period in this case). You would need to modify hyphenation settings. Using something like \setlength{\rightskip}{0pt plus 1 fil} works. However, this will change hyphenation for the rest of the document. To limit it to a single paragraph, you probably want something like this:

\begingroup
\setlength{\rightskip}{0pt plus 1 fil}
<paragraph with \mintedinline that won't normally break>
\endgroup

from minted.

gpoore avatar gpoore commented on July 19, 2024

The "I want automatic line breaks for long lines" applies to environments only. I've clarified the docs.

The current implementation of \mintinline uses BVerbatim from fancyvrb. This gives inline verbatim content, but will not allow line wrapping. The standard \verb behaves the same way (for example, see this).

It seems possible to do what you want, but it will require a completely new version of BVerbatim to eliminate the \hboxes etc. And eliminating those may introduce other issues. So it may be a while till I can get this working.

from minted.

tsdh avatar tsdh commented on July 19, 2024

Ok, thanks for the quick answer.

from minted.

gembez avatar gembez commented on July 19, 2024

@gpoore how can I define the option?

from minted.

benkuly avatar benkuly commented on July 19, 2024

I've the same problem as @gembez
His \mintinline[breaklines]{xml}{spring-boot-starter-test} should be in a new line as well as a pure string spring-boot-starter-test is.

from minted.

benkuly avatar benkuly commented on July 19, 2024

Hm okay, but this only works when I want to break within the \mintinline. If I e.g. have a long class-name like \mintinline[breaklines]{java}{AbstractSecurityInterceptor} I don't want a break within the name. I want it completely on a new line if it dont fit on the same line. But actually I get the message Underfull \hbox (badness 4819) in paragraph. The command \emergencystretch 3em helps that it is on a new line, but that is only a workaroud. Maybe I missed something?

from minted.

gpoore avatar gpoore commented on July 19, 2024

@benkuly If you're dealing with a case where a break within the \mintinline isn't an option and you're getting \hbox messages, then you will have to use paragraph-level commands like \emergencystretch to get things to look acceptable. \mintinline doesn't have any information about its position in the line or overall paragraph layout, so it can't really turn these kinds of things on automatically. At that point, dealing with \mintinline is just like dealing with something like a very long number that can't be hyphenated, and thus requires manual adjustment to paragraph layout using \emergencystretch, \sloppy, or something similar, depending on the document context.

from minted.

benkuly avatar benkuly commented on July 19, 2024

Thank you very much 👍 👍

from minted.

ArchetypeLinuxTux avatar ArchetypeLinuxTux commented on July 19, 2024

When I try to use the code given by gpoore:

\usepackage{minted}
\makeatletter
\renewcommand{\minted@inputpyg}{%
  \expandafter\let\expandafter\minted@PYGstyle%
    \csname PYG\minted@get@opt{style}{default}\endcsname
  \VerbatimPygments{\PYG}{\minted@PYGstyle}%
  \ifthenelse{\boolean{minted@isinline}}%
   {\ifthenelse{\equal{\minted@get@opt{breaklines}{false}}{true}}%
    {\let\FV@BeginVBox\relax
     \let\FV@EndVBox\relax
     \def\FV@BProcessLine##1{%
       \FancyVerbFormatLine{%
         \FV@BreakByTokenAnywhereHook
         \FancyVerbFormatText{\FancyVerbBreakStart##1\FancyVerbBreakStop}}}%
     \minted@inputpyg@inline}%
    {\minted@inputpyg@inline}}%
   {\minted@inputpyg@block}%
}
\makeatother

This does not make \mintinline[breaklines, breakbefore=.]{java}{tesssssssssssssssssssssssssssssssssssssssssssssssssssst.breaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaak} break for me. So it doesn't work for me.

Anyways, I can't find the word breakafter in the code.

from minted.

caniko avatar caniko commented on July 19, 2024

What about documents with custom margins?

from minted.

gpoore avatar gpoore commented on July 19, 2024

@caniko2 Custom margins shouldn't affect breaklines, unless the custom margins are used to define very narrow columns that make hyphenation difficult. In that case, you may need to work with breakbefore, breakafter, or custom hyphenation settings in addition to just using breaklines. All line breaking is using TeX's normal hyphenation, so breaklines should work anywhere that hyphenation would.

from minted.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.