Hallo, ich verwende das Listings-Paket und möchte mir eine eigene Sprache definieren. Die Sprache ist eine Kombinatio aus HTML und Javascript. Kann mir jemand sagen, warum der Javascript-Code nicht wie angegeben in der Farbe Magenta dargestellt wird (siehe keywordstyle = [3]...)? Die Keywords für keywordstyle = [2] werden dagegen korrekt in der Farbe Purple dargestellt. \documentclass[12pt,a4paper,oneside,addpoints]{exam} \usepackage{listings} \usepackage{tikz} \usepackage{xcolor} %Define Colors \definecolor{lightgray}{rgb}{0.95, 0.95, 0.95} \definecolor{darkgray}{rgb}{0.4, 0.4, 0.4} \definecolor{purple}{rgb}{0.65, 0.12, 0.82} \definecolor{editorGray}{rgb}{0.95, 0.95, 0.95} \definecolor{editorOcher}{rgb}{1, 0.5, 0} % #FF7F00 -> rgb(239, 169, 0) \definecolor{editorGreen}{rgb}{0, 0.5, 0} % #007C00 -> rgb(0, 124, 0) \definecolor{orange}{rgb}{1,0.45,0.13} \definecolor{olive}{rgb}{0.17,0.59,0.20} \definecolor{brown}{rgb}{0.69,0.31,0.31} \definecolor{purple}{rgb}{0.90,0.18,0.19} \definecolor{lightblue}{rgb}{0.1,0.57,0.7} \definecolor{lightred}{rgb}{1,0.4,0.5} \definecolor{violett}{rgb}{0.4,0,0.5} \lstloadlanguages{HTML} \usepackage{caption} \DeclareCaptionFont{white}{\color{white}\sffamily} \DeclareCaptionFormat{listing}{\colorbox{blue}{\parbox{\textwidth}{\hspace{15pt}#1#2#3}}} \captionsetup[lstlisting]{format=listing,labelfont=white,textfont=white, singlelinecheck=false, margin=0pt, font={bf,footnotesize}} \lstloadlanguages{HTML} \lstdefinelanguage{HTML5}{ language=html, sensitive=true, tagstyle=\color{blue}, % html keywords keywords = [1]{<,>,/>,<body>,<div, </div>,</body>,<h1>,</h1>,<head>,</head>,<header>,</header>,<html>,</html>,<meta,<p>,</p>,<script,</script>,<title>,</title>,<ul>,</ul>}, % attribute keywords morekeywords = [2]{class, name, type, charset, content}, % javascript morekeywords = [3]{var,for, if, else, function, clearInterval, background, style, setInterval,left,document, getElementById,appendChild,value,createTextNode,createElement}, %Styles keywordstyle = [1]\color{blue}, keywordstyle = [2]\color{purple}, keywordstyle = [3]\color{magenta}, %Comments morecomment = [l]{//}, morecomment = [s]{/*}{*/}, morecomment = [s]{/**}{*/}, morecomment = [s]{<!-}{-->}, commentstyle = \color{editorGreen}, morestring = [b]", morestring = [b]', stringstyle = \color{editorGreen} } \lstset{ % Code language = HTML5, tabsize=2, showtabs=false, showspaces=false, showstringspaces=false, extendedchars=true, breaklines=true, % Support for German umlauts literate=% {Ö}{{\"O}}1 {Ä}{{\"A}}1 {Ü}{{\"U}}1 {ß}{{\ss}}1 {ü}{{\"u}}1 {ä}{{\"a}}1 {ö}{{\"o}}1, % Basic design basicstyle=\footnotesize\sffamily, % Frame Style frame=b, backgroundcolor=\color{yellow!10}, % Line numbers numberstyle=\tiny, xleftmargin=17pt, framexleftmargin=17pt, framexrightmargin=5pt, framexbottommargin=4pt, numbers=left, stepnumber=1, firstnumber=1, numberfirstline=false } \begin{document} \begin{lstlisting}[language=HTML5,caption={Index.html}, label={Script},stepnumber=1,basicstyle=\footnotesize\ttfamily] <html> <!-- Lorem ipsum dolor sit amet --> <head> <title>Lorem ipsum dolor sit amet</title> <meta charset="utf-8" /> <meta name="viewport" content="initial-scale=1"> </head> <body> <script type="text/javascript"> function booking(arg) { var b = document.getElementById("bfield").value; var newText= document.createTextNode(b); var newElement = document.createElement("p"); newElement.appendChild(newText); var s =document.getElementById("s"); s.appendChild(newElement); } </script> <header> <ul> <li>magna aliquyam erat</li> <li>magna aliquyam erat</li> <li>magna aliquyam erat</li> <li>magna aliquyam erat</li> </ul> <h1>Lorem ipsum dolor sit amet</h1> </header> <div class="contentarea"> <h1>Lorem ipsum dolor sit amet, consetetur</h1> <p> Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. </p> </div> </body> </html> \end{lstlisting} \end{document} gefragt 08 Aug '21, 14:36 Error_ |