Varianta A
Sumarizator de fis, iere Markdown
1 Descrierea problemei
Se dă un fis, ier Markdown1 . Se cere realizarea unei sumarizări simpliste a textului din fis, ier,
după regulile prezentate mai jos.
Atent, ie! Există numeroase arome (flavors) de markdown. Vom utiliza ı̂n mod exclusiv
specificat, iile din specificat, ia originală de markdown2 , chiar dacă nu vom utiliza toate aceste
specificat, ii.
2 Reguli pentru sumarizare
Orice element din output va fi indentat cu un număr 3 ∗ n de spat, ii, unde n este cel put, in 1.
Vom numi n nivel de indentare.
Un titlu (header ) de nivel 1 sau 2 va fi indentat la nivel 1, respectiv 2. Toate elementele
subordonate titlului respectiv vor fi indentate cu cel put, in acelas, i nivel de indentare. Un titlu
cu textul “Paragrafe” va fi prezentat la ies, ire ca “+ Paragrafe”. Vor fi suportate atât titlurile
ı̂n format atx cât s, i Setex (vezi referint, a de sintaxă).
Titlurile ı̂n format atx vor fi considerate ca atare numai dacă sublinierea este de aceeas, i lungime
ca s, i cont, inutul titlului. Pentru titlurile ı̂n format Setex “ı̂nchise” (care au un număr oarecare
de # la sfârs, it) nu se va afis, a s, i ı̂nchiderea.
Un titlu de nivel 3 sau mai mare va fi indentat la nivelul 3, s, i va fi afis, at la fel ca un titlu de
nivel 1 sau 2.
Un paragraf va fi reprezentat doar prin prima propozit, ie din paragraf (până la un semn de
punctuat, ie diferit de virgulă sau până la o linie goală), ı̂ncadrată de :. Afis, area sumarizării
paragrafului ı̂n ies, ire se va plasa la nivelul de indentare curent. Un paragraf cu textul “I am
hungry. I will eat some chicken. With fries.” va fi afis, at ı̂n ies, ire ca :I am hungry:. Sumarizarea
unui paragrafului va cont, ine, ı̂n afară de prima propozit, ie, s, i orice alte elemente accentuate sau
linkuri. Astfel, un paragraf cu textul “I am *so hungry* today. I will eat some **chicken**.
With fries .” va fi afis, at ı̂n ies, ire ca :I am <so hungry> today <chicken> <fries>:. Observat, i
ment, inerea marcării eleentelor accentuate s, i ı̂n prima propozit, ie.
1
[Link]
2
Markdown Syntax Documentation [Link]
1
Orice element de accentuare a textului (folosind “*, **, , ”) va fi tradus ı̂n ies, ire ca textul
respectiv ı̂ntre paranteze unghiulare (vezi mai sus).
Un link de forma [an example]([Link] "Title") va fi afis, at ı̂n sumarizare ca [@an
example]. O imagine de forma  va fi sumarizată
ca [!Alt text].
Listele (numerotate sau nu) vor fi sumarizate ca o enumerare a elementelor din listă, ı̂ncadrată
de paranteze drepte, fiecare element fiind sumarizat prin primele maxim 3 cuvinte din element.
Elementele se despart prin ;. Pentru fiecare element, se adaugă s, i orice text accentuat sau
linkuri care urmează ı̂n contextul aceluias, i element, la fel ca s, i la paragrafe. De exemplu, lista
* First, get these ingredients:
* Boil some water.
* Don’t get burned because the water *is hot*
Always remember to be careful when the water is _hot_.
* Dump
everything
in the pot and follow
this algorithm:
va fi sumarizată ca [First, get these; Boil some water; Don’t get burned <is hot> <hot>; Dump
everything in]
Sumarizarea unei liste va fi afis, ată la un nivel de indentare incrementat cu 1 fat, ă de nivelul
curent. Dacă elementul din listă are mai put, in de 3 cuvinte, dar mai are alte paragrafe,
sumarizarea nu va include s, i cuvinte din celelalte paragrafe.
Citatele (blockquotes) vor fi sumarizate ca primele maxim 5 cuvinte din citat, ı̂ncadrate de
". Sumarizarea unui citat va fi afis, at la un nivel de indentare incrementat cu 1 fat, ă de nivelul
curent. Dacă citatul apare ı̂n interiorul unei liste, sumarizarea lui va fi adăugată ı̂n sumarizarea
elementului de listă ı̂n care apare.
Orice bloc de cod va fi sumarizat ca [code]. Dacă blocul apare ı̂ntr-o listă, sumarizarea lui va
fi adăugată ı̂n sumarizarea elementului de listă ı̂n care apare; altfel, sumarizarea va fi adăugată
pe o linie separată, la nivelul de indentare curent.
Dacă apar elemente de cod ı̂n paragrafe, liste, etc, este la alegere dacă dacă ı̂l ignorat, i, ı̂l afis, at, i,
sau nu mai procesat, i cuvintele imediat următoare.
O linie de separare (hr ) va fi reprezentată ca o serie de slash-uri: ////////////
3 Detalii de implementare
Ies, irea se va afis, a pe măsură ce se parcurge fis, ierul; nu se va ret, ine niciun element din input
pentru afis, are ulterioară, ı̂n afară de titlurile de tip atx.
Putet, i folosi C pentru a gestiona nivelul de indentare din afis, are.
2
4 Exemple
Intrare 1:
# main title
## title
### other title
word1 word2 word3 word4 **hello** word 5 _hello_
really this should be a text with meaning.
The meaning is in the words
on one or two
or serveral lines in the paragraph. There are more sentences in a paragraph.
Or use a _graph_.
Here is a short list:
* one item
* two items
* three items
here1
=====
here2
-----
-----
-----
bla
> there is
> more meaning
> in an image than
> in 1000 words
the end.
Ies, ire 1:
+ main title
+ title
+ other title
:word1 word2 word3 word4 <hello> <hello>:
:really this should be a text with meaning:
:The meaning is in the words on one or two or serveral lines in the paragraph:
:Or use a <graph>:
:Here is a short list:
-[one item; two items; three items]
+ here1
3
+ here2
////////////
:bla:
"there is more meaning in"
:the end:
Intrare 2:
An h1 header
============
Paragraphs are separated by a blank line.
2nd paragraph. *Italic*, **bold**, and ‘monospace‘. Itemized lists
look like:
* this one
* that one
* the other one
Note that the actual text
content starts at 4-columns in.
> Block quotes are
> written like so.
>
> They can span multiple paragraphs,
> if you like.
>
> This is the first level of quoting.
>
> > This is nested blockquote.
>
> Back to the first level.
Use 3 dashes for an em-dash. Use 2 dashes for ranges (ex., "it’s all
in chapters 12--14"). Three dots ... will be converted to an ellipsis.
Unicode is supported.
An h2 header
------------
Here’s a list of code stuffs:
1. a for cycle here (from [here](python website)):
# Let me re-iterate ...
for i in 1 .. 10 { do-something(i) }
2. a function like this:
define foobar() {
print "Welcome to flavor country!";
}
Note how the function can be declared as _static_.
4
3. one last
import time
# Quick, count to ten!
for i in range(10):
# (but not *too* quick)
[Link](0.5)
print i
Note again how the actual text starts at 4 columns in (4 characters
from the left side).
### An h3 header ###
Now a new list:
* First, get these ingredients:
* Boil some water.
* Don’t get burned because the water *is hot*
* Dump
everything
in the pot and follow
this algorithm:
find wooden spoon
uncover pot
stir
cover pot
balance wooden spoon precariously on pot handle
wait 10 minutes
goto first step (or shut off burner when done)
Do not bump wooden spoon or it will fall.
Notice again how text always lines up on 4-space indents (including
that last line which continues item 3 above).
Here’s a link to [a website]([Link] to a [local
doc]([Link]), and to a [section heading in the current
doc](#an-h2-header). Here’s a footnote [^1].
[^1]: Footnote text goes here.
# Some other markdown flavors support:
Tables can look like this:
Table: Shoes, their sizes, and what they’re made of
A horizontal rule follows.
***
Here’s a definition list:
apples
: Good for making applesauce.
oranges
5
: Citrus!
tomatoes
: There’s no "e" in tomatoe.
Again, text is indented 4 spaces. (Put a blank line between each
term/definition pair to spread things out more.)
Here’s a "line block":
| Line one
| Line too
| Line tree
and images can be specified like so:

Inline math equations go in like so: $\omega = d\phi / dt$. Display
math should get its own line and be put in in double-dollarsigns:
$$I = \int \rho R^{2} dV$$
## Some stuff we don’t really care about
And note that you can backslash-escape any punctuation characters
which you wish to be displayed literally.
Ies, ire 2:
+ An h1 header
:Paragraphs are separated by a blank line:
:2nd paragraph <*Italic*> <**bold**>:
[this one; that one; the other one]
:Note that the actual text content starts at 4-columns in:
"Block quotes are written like"
:Use 3 dashes for an em-dash:
+ An h2 header
:Here’s a list of code stuffs:
[a for cycle here [@here] [code]; a function like [code] <static>; one last [code]]
:Note again how the actual text starts at 4 columns in:
+ An h3 header
:Now a new list:
[First, get these; Boil some water; Don’t get burned <is hot>;
Dump everything in [code]]
:Notice again how text always lines up on 4-space indents (including that last line
which continues item 3 above):
:Here’s a link to [@a website], to a [@local doc], and to a [@section heading
in the current doc]
+ Some other markdown flavors support:
:Tables can look like this:
:A horizontal rule follows:
////////////
:Here’s a definition list:
:apples:
:Again, text is indented 4 spaces:
:Here’s a "line block":
[code]
:and images can be specified like so:
[!example image]
:Inline math equations go in like so:
6
+ Some stuff we don’t really care about
:And note that you can backslash-escape any punctuation characters
which you wish to be displayed literally: