Skip to content

Commit

Permalink
Implemented 'disable' for highlighting comment and package option
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-krieg committed May 5, 2021
1 parent f7a5d86 commit 25dccd8
Showing 1 changed file with 31 additions and 20 deletions.
51 changes: 31 additions & 20 deletions newtodo.sty
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%------------------------------------------------------------------------------
%
% This is the 'newtodo' package
% This is the 'review' package
%
% Copyrright (c) 2021 Christian Krieg <christian@drkrieg.at>
%
Expand Down Expand Up @@ -29,8 +29,8 @@
%
% [...]
% \begin{document}
% Define TODO just once
% \newtodo{john}{blue}
% Define reviewer; 'opts' are passed to underlying \todo command
% \reviewer[opts]{john}{blue}
% [...]
%
%
Expand All @@ -48,50 +48,61 @@
%
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{newtodo}
[2021/05/03 v0.01 LaTeX package to define customized TODO noted]
[2021/05/03 v0.01 LaTeX package to define makros for multi-reviewer reviews]
%
%------------------------------------------------------------------------------
%
\ExecuteOptions{\@nameuse{opt@review.sty}}
\RequirePackage[
colorinlistoftodos,
prependcaption,
textsize=footnotesize,
textwidth=1.75cm,
\@nameuse{opt@review.sty},
]{todonotes}
%\RequirePackage{xargs}
\RequirePackage{setspace}
\RequirePackage{soul}
\RequirePackage{xstring}
%
%------------------------------------------------------------------------------
%
\newcommand{\newtodo}[2]{%
\newcommand{\reviewer}[3][]{%
%
% Define TODO note
\expandafter\newcommand\csname #1\endcsname[2][]{%
\expandafter\newcommand\csname #2\endcsname[2][]{%
\todo[
color=#2,
backgroundcolor=#2!25,
bordercolor=#2!50,
linecolor=#2!50,
color=#3,
backgroundcolor=#3!25,
bordercolor=#3!50,
linecolor=#3!50,
tickmarkheight = 1em,
author={\textbf{\expandafter\MakeUppercase #1}},
author={\textbf{\expandafter\MakeUppercase #2}},
caption={},
noprepend,
fancyline,
##1
#1,
##1,
]{
\setstretch{1}##2

}
}%
% Define highlighting TODO note
\makeatletter%
\if@todonotes@disabled%
\expandafter\newcommand\csname #1hl\endcsname[1][]{##1}%
\else%
\expandafter\newcommand\csname #1hl\endcsname[3][]{\hl{##2}\csname#1\endcsname[##1]{##3}}%
\fi%
\makeatother
% Define highlighting TODO note. Only print the selected text as-is if todo
% notes are disabled globally by the 'disable' package option
\if@todonotes@disabled%
\expandafter\newcommand\csname #2hl\endcsname[3][]{##2}%
\else%
\expandafter\newcommand\csname #2hl\endcsname[3][]{%
% We are checking here whether in reviewer options, or local option
% contains "disable". If so, don't highlight the selected text, but
% print it as-is. The todonote is is hidden because the options are
% passed on to the underlying \todo command
\IfSubStr{##1}{disable}{##2}{%
\IfSubStr{#1}{disable}{##2}{\hl{##2}}%
}%
\csname#2\endcsname[##1]{##3}}%
\fi%
}
%
%------------------------------------------------------------------------------
Expand Down

0 comments on commit 25dccd8

Please sign in to comment.