Skip to content

Commit a7ea7b9

Browse files
committed
Add temporary formatter for complete study notes
1 parent 670cb0f commit a7ea7b9

1 file changed

Lines changed: 148 additions & 0 deletions

File tree

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
name: Format Complete Study Notes
2+
3+
on:
4+
push:
5+
paths:
6+
- .github/workflows/format-complete-notes.yml
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
format-notes:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Format complete notes
22+
shell: python
23+
run: |
24+
from pathlib import Path
25+
import re
26+
27+
path = Path('Complete CompTIA Security+ SY0-701 Study Notes.md')
28+
text = path.read_text(encoding='utf-8')
29+
30+
replacements = {
31+
'’': "'",
32+
'‘': "'",
33+
'“': '"',
34+
'�': '"',
35+
'–': '-',
36+
'—': '-',
37+
'…': '...',
38+
'Â ': ' ',
39+
'Â': '',
40+
}
41+
for bad, good in replacements.items():
42+
text = text.replace(bad, good)
43+
44+
text = text.replace('\r\n', '\n').replace('\r', '\n')
45+
lines = text.split('\n')
46+
47+
while lines and not lines[0].strip():
48+
lines.pop(0)
49+
if lines and lines[0].strip().lower() == 'comptia security+ (sy0-701) study notes':
50+
lines.pop(0)
51+
while lines and not lines[0].strip():
52+
lines.pop(0)
53+
54+
main_titles = []
55+
for line in lines:
56+
match = re.match(r'^#\s+(.+?)\s*$', line)
57+
if match:
58+
main_titles.append(match.group(1))
59+
60+
def anchor_for(section_num, title):
61+
base = f'section-{section_num}-{title}'.lower()
62+
base = base.replace('+', '')
63+
base = re.sub(r'[^a-z0-9\s-]', '', base)
64+
base = re.sub(r'\s+', '-', base.strip())
65+
base = re.sub(r'-+', '-', base)
66+
return base
67+
68+
nav_rows = [f'| {i} | [{title}](#{anchor_for(i, title)}) |' for i, title in enumerate(main_titles, 1)]
69+
70+
header = [
71+
'# Complete CompTIA Security+ SY0-701 Study Notes',
72+
'',
73+
'A complete set of CompTIA Security+ SY0-701 study notes organized for quick revision, topic-by-topic review, and full exam preparation.',
74+
'',
75+
'## How To Use These Notes',
76+
'',
77+
'- Use the quick navigation table to jump to a topic.',
78+
'- Read one section at a time, then review the key terms from that section.',
79+
'- Use the official exam objectives to confirm coverage before scheduling the exam.',
80+
'- Build flashcards for definitions, acronyms, controls, attack types, and response steps.',
81+
'- Use authorized labs and practice questions to connect these notes to real scenarios.',
82+
'',
83+
'## Official Exam Links',
84+
'',
85+
'| Resource | Link |',
86+
'| --- | --- |',
87+
'| Official Security+ certification page | [CompTIA Security+](https://www.comptia.org/certifications/security) |',
88+
'| Official SY0-701 exam objectives PDF | [CompTIA Security+ SY0-701 Exam Objectives](https://assets.ctfassets.net/82ripq7fjls2/6TYWUym0Nudqa8nGEnegjG/0f9b974d3b1837fe85ab8e6553f4d623/CompTIA-Security-Plus-SY0-701-Exam-Objectives.pdf) |',
89+
'| Schedule the exam | [Pearson VUE CompTIA Testing](https://www.pearsonvue.com/us/en/comptia.html) |',
90+
'| Buy voucher / training materials | [CompTIA Store](https://store.comptia.org/) |',
91+
'',
92+
'## Exam Domains',
93+
'',
94+
'| Domain | Weight | Focus |',
95+
'| --- | ---: | --- |',
96+
'| 1.0 General Security Concepts | 12% | Security controls, CIA, AAA, zero trust, physical security, cryptography |',
97+
'| 2.0 Threats, Vulnerabilities, and Mitigations | 22% | Threat actors, attack surfaces, vulnerabilities, malware, hardening |',
98+
'| 3.0 Security Architecture | 18% | Enterprise architecture, cloud, infrastructure, resilience, data protection |',
99+
'| 4.0 Security Operations | 28% | IAM, monitoring, vulnerability management, incident response, automation |',
100+
'| 5.0 Security Program Management and Oversight | 20% | Governance, risk, compliance, audits, vendor risk, security awareness |',
101+
'',
102+
'## Quick Navigation',
103+
'',
104+
'| Section | Topic |',
105+
'| ---: | --- |',
106+
*nav_rows,
107+
'',
108+
'---',
109+
'',
110+
]
111+
112+
new_lines = []
113+
section_num = 0
114+
for line in lines:
115+
match = re.match(r'^#\s+(.+?)\s*$', line)
116+
if match:
117+
section_num += 1
118+
if section_num > 1:
119+
while new_lines and not new_lines[-1].strip():
120+
new_lines.pop()
121+
new_lines.extend(['', '<p align="right"><a href="#complete-comptia-security-sy0-701-study-notes">Back to top</a></p>', '', '---', ''])
122+
new_lines.append(f'## Section {section_num}: {match.group(1)}')
123+
elif line.startswith('## '):
124+
new_lines.append('#' + line)
125+
elif line.startswith('### '):
126+
new_lines.append('#' + line)
127+
elif line.startswith('#### '):
128+
new_lines.append('#' + line)
129+
else:
130+
line = re.sub(r'^(\s*)-\s{2,}', r'\1- ', line)
131+
new_lines.append(line.rstrip())
132+
133+
formatted = '\n'.join(header + new_lines).strip() + '\n'
134+
path.write_text(formatted, encoding='utf-8')
135+
136+
- name: Remove temporary workflow and commit
137+
shell: bash
138+
run: |
139+
rm -f .github/workflows/format-complete-notes.yml
140+
git config user.name "github-actions[bot]"
141+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
142+
git add "Complete CompTIA Security+ SY0-701 Study Notes.md" .github/workflows/format-complete-notes.yml
143+
if git diff --cached --quiet; then
144+
echo "No changes to commit"
145+
else
146+
git commit -m "Format complete Security+ study notes"
147+
git push
148+
fi

0 commit comments

Comments
 (0)