Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7f506c0

Browse files
getContents agora usa $ como div char ao inves de tab
1 parent bf89ce5 commit 7f506c0

File tree

6 files changed

+56
-50
lines changed

6 files changed

+56
-50
lines changed

‎SH12-Notebook.pdf

-6.96 KB
Binary file not shown.

‎pdf/README.md

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,10 @@
22

33
Para gerar o pdf execute o script shell.
44

5-
Windows:
65
```shell
76
sh .\generate_pdf.sh
87
```
98

10-
Ou linux:
11-
```shell
12-
.\generate_pdf.sh
13-
```
14-
159
Necessário que haja suporte para C++ e [latexmk](https://www.ctan.org/pkg/latexmk/)!
1610

1711
```shell
@@ -28,7 +22,7 @@ Para remover algum dos códigos do PDF, remova ou comente a linha dele com ```#`
2822

2923
Para gerar novamente a lista com todos os códigos e extras, rode:
3024
```shell
31-
python3 .\getContents.py
25+
python3 .\getContents.py> .\contents.txt
3226
```
3327

3428
## 📚 Extras
@@ -43,9 +37,9 @@ Você também pode adicionar seu arquivo tex diretamente na pasta de códigos. N
4337

4438
**Se você for gerar sua própria Lib**, provavelmente vai querer alterar essas partes dos códigos:
4539

46-
- [generate_latex.cpp](generate_latex.cpp): ```const string code_dir = "../Library";``` coloque o path (relativo) para a pasta com os seus códigos. (Obs: a ```string title``` não é usada para nada, apenas para um cout ao iniciar o código).
40+
- [generate_latex.cpp](generate_latex.cpp): Tem muitas opções de personalização que você pode ou não querer, veja os detalhes em *":wrench: Outras personalizações"*.
4741

48-
- [getContents.py](getContents.py): assim como no anterior, altere ```code_dir = "../Library"``` para o path dos seus códigos. **Lembre de rodar o getContents antes para ter a lista com os seus códigos!** <small>Confira também o arquivo para ver se todos os códigos que você quer estão lá e para remover coisas que você não quer que entrem.</small>
42+
- [getContents.py](getContents.py): Assim como no anterior, altere ```code_dir = "../Library"``` para o path dos seus códigos. **Lembre de rodar o getContents antes para ter a lista com os seus códigos!** <small>Confira também o arquivo para ver se todos os códigos que você quer estão lá e para remover coisas que você não quer que entrem.</small>
4943

5044
- [notebook.tex](notebook.tex): Se quiser mudar a quantidade de colunas, altere ```\begin{multicols*}{3}``` na linha ```119```. Mude também essas opções de títulos do seu PDF.
5145
```tex
@@ -54,21 +48,23 @@ Você também pode adicionar seu arquivo tex diretamente na pasta de códigos. N
5448
\title{\vspace{-4ex}\Large{SamuellH12 - ICPC Library}} %line 113
5549
```
5650

57-
- Opcional [generate_pdf.sh](generate_pdf.sh): O pdf gerado está sendo renomeado e movido para a pasta parent da atual. ```mv notebook.pdf ../SH12-Notebook.pdf``` (obs: só não renomeio para notebook.pdf)
51+
- Opcional [generate_pdf.sh](generate_pdf.sh): O pdf gerado está sendo renomeado e movido para a pasta parent da atual. ```mv notebook.pdf ../SH12-Notebook.pdf``` (obs: só não renomeie para notebook.pdf)
5852

59-
### 🛠 Outras personalizações
53+
### :wrench: Outras personalizações
6054

6155
Em [notebook.tex](notebook.tex) você pode personalizar configuraçãos do Latex como cor dos códigos, tamanho das fontes, orientação e tamanho da folha... e tudo mais que possa ser personalizado no Latex.
6256

6357
Edite o arquivo [generate_latex.cpp](generate_latex.cpp) para alterar opções como:
6458

65-
- IGNORED_LINES: ignora **linhas inteiras** com determinados valores de substring (ex: ```#include <bits/stdc++.h>"```, ```"using namespace std;```, ```#define pii pair<int, int>```).Cuidado para não remover algo que você não gostaria que fosse removido.
59+
- **IGNORED_LINES**: ignora **linhas inteiras** com determinados valores de substring (ex: ```#include <bits/stdc++.h>"```, ```"using namespace std;```, ```#define pii pair<int, int>```).Cuidado para não remover algo que você não gostaria que fosse removido.
6660

67-
- IGNORED_SUBSTRINGS: ignora substrings específicas no código (ex: ```std::```).
61+
- **IGNORED_SUBSTRINGS**: ignora substrings específicas no código (ex: ```std::```).
62+
63+
- **IGNORED_INTERVAL**: ignora um intervalo do texto, desde a linha que tem ```LATEX_IGNORED_BEGIN``` até a linha com ```LATEX_IGNORED_END``` (inclusivo).
6864

69-
- Caracteres alterados: caracteres latinos como à, ã, é, ç, etc... são alterados para a, e, c e etc, para evitar conflitos com o LaTex e caracteres .
65+
- **Caracteres alterados**: caracteres latinos como à, ã, é, ç, etc... são alterados para a, e, c e etc, para evitar conflitos com o LaTex e caracteres .
7066

71-
- Descrição: O código interpreta trechos do arquivo do código como descrição e adiciona essa descrição no pdf em uma caixa logo antes do código. Mais especificamente trechos entre comentários específicos: ```/*LATEX_DESC_BEGIN Isso é uma descrição! LATEX_DESC_END*/```. Para permitir ou não, altere ```bool ADD_DESC = true;```. Algumas formatações suportadas:
67+
- **Descrição**: O código interpreta trechos do arquivo do código como descrição e adiciona essa descrição no pdf em uma caixa logo antes do código. Mais especificamente trechos entre comentários específicos: ```/*LATEX_DESC_BEGIN Isso é uma descrição! LATEX_DESC_END*/```. Para permitir ou não, altere ```bool ADD_DESC = true;```. (cuidado com o IGNORED_LINES, está configurado para ignorar essas linhas). Algumas formatações suportadas (pode ser desabilitado em ```const bool USE_MARKDOWN_IN_DESC = true;```):
7268
- **bold** com `**bold**`
7369
- *Itálico* com `_.Italico_.`
7470
- `código inline` com ``` `codigo inline` ```

‎pdf/contents.txt

2.27 KB
Binary file not shown.

‎pdf/generate_latex.cpp

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
#include <regex>
33
using namespace std;
44

5-
const string code_dir = "../Library";
6-
const string title = "SamuellH12 - ICPC Library";
75

86
const vector<string> IGNORED_LINES = {
97
"#include <bits/stdc++.h>",
@@ -31,6 +29,7 @@ const string IGNORED_INTERVAL_BGN = "LATEX_IGNORED_BEGIN";
3129
const string IGNORED_INTERVAL_END = "LATEX_IGNORED_END";
3230

3331
const bool ADD_DESC = true;
32+
const bool USE_MARKDOWN_IN_DESC = true;
3433
const string DESC_BGN = "LATEX_DESC_BEGIN";
3534
const string DESC_END = "LATEX_DESC_END";
3635
// const string MY_DESC_BGN = "/********";
@@ -54,6 +53,8 @@ map<char32_t, char> char_changes = {
5453
{U'\x2019', '\''}, {U'\x3b1', 'a'}, {U'\x2013', '-'},
5554
};
5655

56+
//// Code Start Here ////
57+
5758
void remove_ignored_substrings(string& s) {
5859
size_t pos = 0;
5960
for(const auto& substr : IGNORED_SUBSTRINGS)
@@ -124,7 +125,7 @@ string convert_description(const string& description) {
124125
s += line;
125126
}
126127

127-
return parse_markdown(s);
128+
return USE_MARKDOWN_IN_DESC ? parse_markdown(s) : s;
128129
}
129130

130131
bool is_comment(string line) {
@@ -221,20 +222,13 @@ string get_tex(const vector<pair<string, vector<pair<string, string>>>>& section
221222
for(auto& [section_name, subsections] : sections) if(!subsections.empty()){
222223
tex += "\\section{" + section_name + "}\n";
223224

224-
for(auto [filename, subsection_name] : subsections) {
225-
if(subsection_name == "tex"){
226-
tex += "\\input " + filename + "\n";
227-
continue;
228-
}
229-
if(get_style(filename) == "tex"){
230-
tex += "\\input{" + code_dir + "/" + filename + "}\n";
231-
continue;
232-
}
225+
for(auto [filename, subsection_name] : subsections){
226+
cout << get_style(filename) + "\t| " << filename << endl;
227+
if(get_style(filename) == "tex"){ tex += "\\input{" + filename + "}\n"; continue; }
233228

234-
string full_path = code_dir + "/" + filename;
235-
cout << full_path << endl;
229+
string newpath = "./temp/" + filename, full_path = filename;;
230+
newpath = regex_replace(newpath, regex(R"(\.\./)"), ""); // remove qualquer ../ de newpath
236231

237-
string newpath = "./temp/" + filename;
238232
if(convert_files(full_path, newpath, description, PRINT_HASH))
239233
full_path = newpath;
240234

@@ -270,6 +264,9 @@ vector<pair<string, vector<pair<string, string>>>> get_sections() {
270264
if (bom[0] != (char)0xFF || bom[1] != (char)0xFE){ f.seekg(0); }
271265

272266
string line;
267+
char div_char; // Default divisor character
268+
f >> div_char;
269+
273270
while(getline(f, line))
274271
{
275272
line.erase(remove(line.begin(), line.end(), '\r'), line.end());
@@ -280,16 +277,19 @@ vector<pair<string, vector<pair<string, string>>>> get_sections() {
280277

281278
if(line[0] == '[') sections.emplace_back(line.substr(1, line.size() - 2), vector<pair<string, string>>());
282279
else {
283-
size_t tab_pos = line.find('\t');
284-
if (tab_pos >= line.size()) {
285-
cerr << "\n\n\n\nSubsection parse error {" << line << "} " << line.size() << "\n\n\n\n\n";
286-
for(auto c : line) cerr << int(c) << '|'; cerr << endl;
280+
size_t div_pos = line.find(div_char);
281+
if (div_pos >= line.size()) {
282+
cerr << "\n\n\n\nSubsection parse error {" << line << "} " << line.size() << "\n";
283+
cerr << "Is the DIVISOR character correct? It should be '" << div_char << "'\n";
287284
continue;
288285
}
289286

290-
string filename = line.substr(0, tab_pos);
291-
string subsection_name = line.substr(tab_pos + 1);
292-
287+
string filename = line.substr(0, div_pos);
288+
while(!filename.empty() && (filename.back() == ' ' || filename.back() == '\t')) filename.pop_back();
289+
string subsection_name = line.substr(div_pos + 1);
290+
while(!subsection_name.empty() && (subsection_name.back() == ' ' || subsection_name.back() == '\t')) subsection_name.pop_back();
291+
while(!subsection_name.empty() && (subsection_name.front() == ' ' || subsection_name.front() == '\t')) subsection_name.erase(0, 1);
292+
293293
if(sections.empty()) {
294294
cerr << "Subsection given without section {" << line << "} " << line.size() << endl;
295295
continue;
@@ -303,9 +303,7 @@ vector<pair<string, vector<pair<string, string>>>> get_sections() {
303303
}
304304

305305

306-
int main(){
307-
cout << title << endl;
308-
306+
int main(){
309307
auto sections = get_sections();
310308
string tex = get_tex(sections, USE_HASH);
311309

‎pdf/generate_pdf.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@ set -e
55
g++ -std=c++17 -o genLatex generate_latex.cpp -O2 -lssl -lcrypto
66
./genLatex
77

8-
pdflatex notebook.tex
9-
latexmk -pdf -f notebook.tex
8+
pdflatex -quiet -halt-on-error -file-line-error notebook.tex
9+
latexmk -pdf -f -silent notebook.tex
1010
mv notebook.pdf ../SH12-Notebook.pdf
1111
rm contents.tex
1212
mv notebook.tex _notebook.tex
1313
rm notebook.*
1414
mv _notebook.tex notebook.tex
1515
rm genLatex.exe
16-
rm ./temp -r
16+
rm ./temp -r
17+
18+
echo "
19+
Spinosaurus says: All done! =]
20+
Good luck and good contest!
21+
"

‎pdf/getContents.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
import os
22

33
code_dir = "../Library"
4-
extra_dir = "./extra"
4+
extra_dir = "./extra" # const
5+
div_char = '$'
56

6-
note = '''
7+
print(div_char)
8+
print("# First line is the divisor character used to separate the file name from it's title!!!\n# Don't change the first line!!!")
9+
10+
11+
note = f'''
712
# Any line followed by a '#' character is ignored
813
# Section headings must be in square brackets
914
# Subsections within a section should follow the format:
10-
# [filename within code directory][tab character\t][subsection title]
11-
# tab character:
15+
# (filename within code directory)(divisor character:{div_char})(subsection title)
16+
# div character:{div_char}
1217
'''
1318
print(note)
1419

@@ -18,16 +23,18 @@
1823
if(len(files) == 0): continue
1924

2025
print(f'[{dir}]')
26+
longestPath = max([len(arquivo) if '.exe' not in arquivo else 0 for arquivo in files])
2127
for arquivo in files:
2228
if('.exe' in arquivo): continue
23-
print(f"{dir}/{arquivo}\t{arquivo.split('.')[0]}")
29+
print(f"{code_dir}/{dir}/{arquivo}{' '*(longestPath-len(arquivo))}{div_char}{arquivo.split('.')[0]}")
2430

2531
print()
2632

2733
print()
28-
print("#Extra content - tex files")
34+
print("## Extra content - tex files ##")
2935
print('[Extra]')
3036

3137
for arquivo in os.listdir(extra_dir):
38+
longestName = max([len(arquivo) if '.exe' not in arquivo else 0 for arquivo in files])
3239
if(os.path.isfile(os.path.join(extra_dir, arquivo))):
33-
print(f"{extra_dir}/{arquivo}\ttex")
40+
print(f"{extra_dir}/{arquivo}{' '*(longestPath-len(arquivo))}{div_char}tex")

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /