Esta questão é a extensão desta questão sobre listar questões de diretórios .
Eu tenho um problema que eu preciso entender a seção original do texto.
Saída atual
ondevocêvêasegundaperguntanãofazsentido.FoiincluídonaarteritedeTakayasusubsection
nodiretórioRheumatology:
\subsection{Takayasuarteritis}\begin{question}{Yougetapatient.Whatdoyounoticefirstinthispatient?}Absenceofperipheralpulse.\end{question}Loremipsum.\begin{question}{WhatwasthefirstTakayasucase?}YoungwomaninAsiawithredvesselsintheeye.Sospecialeyediagnosisdone.Affectseye.\end{question}
emqueasaídaatualéporesseexcelente código
\section{Rheumatology}
\begin{question}
{You get a patient.
What do you notice first in this patient?}
Absence of peripheral pulse.
\end{question}
\begin{question}
{What was the first Takayasu case?}
Young woman in Asia with red vessels in the eye.
So special eye diagnosis done.
Affects eye.
\end{question}
mas gostaria que fosse
\section{Rheumatology}
\subsection{Takayasu arteritis}
\begin{question}
{You get a patient.
What do you notice first in this patient?}
Absence of peripheral pulse.
\end{question}
\begin{question}
{What was the first Takayasu case?}
Young woman in Asia with red vessels in the eye.
So special eye diagnosis done.
Affects eye.
\end{question}
Minha proposta é incluir subseções se houver perguntas na subseção.
Meu pseudocódigo
Look for the environment \begin{question}...\end{question}.
See the subsection of the question (it locates above the question).
If there is no subsection, leave blank.
If there are many questions within one subsection, put only one subsection.
Código de Terdon
#!/usr/bin/env bash
## avoid errors if a directory has no *tex files
shopt -s nullglob
directories=("Cardiology" "Rheumatology" "Surgery");
## Change this to set whichever options you want.
printf "%s\n%s\n" "\documentclass{YOURCLASS}" "\begin{document}"
for directory in ${directories[@]}
do
## Reset the counter, avoid empty sections.
c=0;
for file in "$directory"/*tex
do
let c++
[ "$c" -eq 1 ] && printf "\n%s\n" "\section{$directory}"
## Extract the wanted lines
perl -lne '$a=1 && print "" if /\begin{question}/;
print if $a==1;
$a=0 if /\end{question}/;' "$file"
echo ""
done
done
echo "\end{document}"
onde eu acho que a lógica dessas linhas deve ser alterada
## Extract the wanted lines
perl -lne '$a=1 && print "" if /\begin{question}/;
print if $a==1;
$a=0 if /\end{question}/;' "$file"
echo ""
que usa um regex para encontrar todas as perguntas em um arquivo E ignora as subseções das perguntas.
Exemplo de dados (pouco diferente do último caso!)
\subsection{Takayasu arteritis}
\begin{question}
{You get a patient.
What do you notice first in this patient?}
Absence of peripheral pulse.
\end{question}
\begin{question}
{What was the first Takayasu case?}
Young woman in Asia with red vessels in the eye.
So special eye diagnosis done.
Affects eye.
\end{question}
Fever of unknown origin can be used when you do not know what is causing the disease.
% Show cases in MedScape and ask class.
Aneurysms.
\subsubsection{Treatment}
\begin{question}
{What you should always include in Takayasu treatment?
What are the symptoms?}
Blood pressure.
Aneurysms which will burst without treatment.
So blood pressure decreasing drugs like beta blockers along in combination with other drugs.
\end{question}
\begin{question}
{When is the checkup of the Takayasu arteritis?}
Only once per year.
You could expect every month like normally in this kind of diseases.
But only once per year.
\end{question}
onde você pode ignorar subsubsections no aplicativo.
Como você pode escrever o pseudocódigo?
Bug no código de Terdon 14.10.2014 encontrado
Exemplo de dados que causam o bug
\subsection{3}
A 55 y.o male says that for the last year ...
\begin{question}
{What is the pathogenetic mechanism of his complains?}
\end{question}
que analisado pelo código de Terdon dá exatamente o mesmo resultado que está errado, já que a sentença A 55 y.o ... não deveria estar mais lá no resultado final.
Se houver uma entrada entre a subseção e o texto do corpo, corrija a saída.
No entanto, isso não pode ser assumido.
A causa deste bug são os símbolos do Windows, movidos aqui .