Guest User

Untitled

a guest
Sep 10th, 2018
152
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. \documentclass{article}
  2.  
  3. \usepackage[dvipsnames]{xcolor}
  4. \definecolor{strings}{HTML}{448c25}
  5. \definecolor{comments}{HTML}{aaaaaa}
  6. \definecolor{keywords}{HTML}{aa3d8c}
  7. \definecolor{background}{HTML}{f4f4f4}
  8. \definecolor{numbers}{HTML}{a884e0}
  9. \definecolor{rfc}{HTML}{4e85cd}
  10.  
  11. \usepackage{listings}
  12. \makeatletter
  13. \DeclareRobustCommand{\filename}[1]{
  14.    \begingroup
  15.        \def\textendash{-}
  16.        \filename@parse{#1}
  17.        \edef\filename@base{\detokenize\expandafter{\filename@base}}
  18.        \filename@base.\filename@ext
  19.    \endgroup
  20. }
  21. \makeatother
  22. \lstdefinestyle{default}{
  23.    backgroundcolor=\color{background},
  24.    basicstyle=\ttfamily\small,
  25.    breakatwhitespace=true,
  26.    breaklines=true,
  27.    commentstyle=\color{comments},
  28.    deletekeywords={},
  29.    escapeinside={}{},
  30.    extendedchars=true,
  31.    frame=lines,
  32.    keepspaces=true,
  33.    keywordstyle=\color{keywords},
  34.    morekeywords={},
  35.    numbers=left,
  36.    numberstyle=\color{numbers},
  37.    rulecolor=\color{numbers},
  38.    showspaces=false,
  39.    showstringspaces=false,
  40.    showtabs=false,
  41.    stepnumber=1,
  42.    stringstyle=\color{strings},
  43.    tabsize=2,
  44.    title=\filename{\lstname}
  45. }
  46.  
  47. \lstset{
  48.    style=default,
  49. }
  50.  
  51. \lstdefinelanguage{cisco-terminal}{
  52.    basicstyle=\ttfamily\footnotesize\color{keywords},
  53.    morecomment=[l][\color{black}]{\#},
  54.    morecomment=[l][\color{black}]{>},
  55.    morecomment=[s][\color{strings}]{*}{'},
  56.    morecomment=[s][\color{strings}]{`}{'},
  57.    numbers=left
  58. }
  59.  
  60. \begin{document}
  61.  
  62. \section{Wrongly highlighted code}
  63. As you can see, the code is wrongly formatted after line 13 (continues to be green).
  64. \begin{lstlisting}[language=cisco-terminal]
  65. sw04-pod-X>!Type the following commands
  66. sw04-pod-X>en
  67. sw04-pod-X#conf t
  68. sw04-pod-X(config)#hostname internet
  69. internet(config)#ip routing
  70. internet(config)#do sh run
  71. *** OUTPUT OMITTED ***
  72. !
  73. interface GigabitEthernet1/0/23
  74.  switchport mode access
  75.  switchport access vlan 123
  76. !
  77. !
  78. internet(config)#interface GigabitEthernet1/0/23
  79. internet(config-if)#no switchport
  80. internet(config-if)#ip address 99.88.1.1 255.255.255.252
  81. internet(config-if)#interface GigabitEthernet1/0/24
  82. internet(config-if)#no switchport
  83. internet(config-if)#ip address 99.88.2.1 255.255.255.252
  84. internet(config-if)#exit
  85. internet(config)#ip route 155.11.1.0 255.255.255.0 99.88.1.2
  86. internet(config)#ip route 155.11.2.0 255.255.255.0 99.88.2.2
  87. internet(config)#do sh run
  88. *** OUTPUT OMITTED ***
  89. !
  90. interface GigabitEthernet1/0/23
  91.  ip address 99.88.1.1 255.255.255.252
  92. !
  93. !
  94. internet(config)#exit
  95. internet#sh ip bgp
  96.   Network     Next Hop        Metric      LocPrf  Weight  Path
  97.  
  98. \end{lstlisting}
  99.  
  100. \section{Correct highlighted, but with ugly workaround}
  101. The only workaround I found, was adding ' and ` symbols. As they are printed, this is an ugly solution. However, the output color is correct.
  102. \begin{lstlisting}[language=cisco-terminal]
  103. sw04-pod-X>!Type the following commands
  104. sw04-pod-X>en
  105. sw04-pod-X#conf t
  106. sw04-pod-X(config)#hostname internet
  107. internet(config)#ip routing
  108. internet(config)#do sh run
  109. *** OUTPUT OMITTED ***
  110. !
  111. interface GigabitEthernet1/0/23
  112.  switchport mode access
  113.  switchport access vlan 123
  114. !
  115. !'
  116. internet(config)#interface GigabitEthernet1/0/23
  117. internet(config-if)#no switchport
  118. internet(config-if)#ip address 99.88.1.1 255.255.255.252
  119. internet(config-if)#interface GigabitEthernet1/0/24
  120. internet(config-if)#no switchport
  121. internet(config-if)#ip address 99.88.2.1 255.255.255.252
  122. internet(config-if)#exit
  123. internet(config)#ip route 155.11.1.0 255.255.255.0 99.88.1.2
  124. internet(config)#ip route 155.11.2.0 255.255.255.0 99.88.2.2
  125. internet(config)#do sh run
  126. *** OUTPUT OMITTED ***
  127. !
  128. interface GigabitEthernet1/0/23
  129.  ip address 99.88.1.1 255.255.255.252
  130. !
  131. !'
  132. internet(config)#exit
  133. internet#sh ip bgp
  134. `   Network     Next Hop        Metric      LocPrf  Weight  Path
  135. '
  136. \end{lstlisting}
  137.  
  138. \end{document}
RAW Paste Data