Пишем программу для создания книг FB2 (СИ) - Карпов Юрий

На нашем литературном портале можно бесплатно читать книгу Пишем программу для создания книг FB2 (СИ) - Карпов Юрий, Карпов Юрий . Жанр: Программное обеспечение. Онлайн библиотека дает возможность прочитать весь текст и даже без регистрации и СМС подтверждения на нашем литературном портале fplib.ru.
Пишем программу для создания книг FB2 (СИ) - Карпов Юрий
Название: Пишем программу для создания книг FB2 (СИ)
Дата добавления: 16 сентябрь 2020
Количество просмотров: 260
Читать онлайн

Помощь проекту

Пишем программу для создания книг FB2 (СИ) читать книгу онлайн

Пишем программу для создания книг FB2 (СИ) - читать бесплатно онлайн , автор Карпов Юрий
1 ... 5 6 7 8 9 ... 12 ВПЕРЕД

const

max = 5;

mas: array[1..max] of string =

(

'<?xml version="1.0" encoding="windows-1251"?>',

'<FictionBook xmlns="http://www.gribuser.ru/xml/fictionbook/2.0"',

' xmlns: l="http://www.w3.org/1999/xlink">',

' <description>',

' <title-info>'

);

var

i: byte;

S: string;

begin

// head

for i:= 1 to max do

OutList.Add(Mas[i]);

with form1.GenresBox do

if Items.Count > 0 then

for i:= 0 to Items.Count - 1 do

OutList.Add('<genre>'+GetGaner(Items[i])+'</genre>');

SavePersons('author',Form1.ListBox3);

SavePersons('translator',Form1.ListBox2);

with Form1 do

begin

PrintString('book-title',book_title.text);

if Annotation.Lines.Count > 0

then SaveAnnotation;

//if _date.text <> '' then

//OutList.Add('<date value="'+_date.text+'-01-01">'+_date.text+'</date>');

SaveSequence;

OutList.Add(' <lang>'+Lang.Text+'</lang>');

if SLang.ItemIndex > -1 then

begin

S:= Lg[SLang.ItemIndex][1];

if S <> '' then

OutList.Add(' <src-lang>'+S+'</src-lang>');

end;

OutList.Add(' </title-info>');

// **** document-info ****

OutList.Add(' <document-info>');

OutList.Add(' <program-used>my_Make_FB2</program-used>');

PrintString('src-url', url.Text); //??

OutList.Add(' <date value="'+FormatDateTime('yyyy-mm-dd', Now)+'">'+ DateToStr(now) +'</date>');

PrintString('id', id.Text); //??

OutList.Add(' <version>1.0</version>');

OutList.Add(' </document-info>');

// **** publish-info ****

OutList.Add(' <publish-info>');

if Book_name.Text = ''

then PrintString('book-name', book_title.Text)

else PrintString('book-name', Book_name.Text);

PrintString('publisher', publisher.Text); //

PrintString('city', city.Text); //

PrintString('year', year.Text); //

PrintString('isbn', isbn.Text); //

//OutList.Add(' <version>1.0</version>');

OutList.Add(' </publish-info>');

end;

OutList.Add(' </description>');

OutList.Add('<body>');

end;

function SubStyle(m,w: TmyStyle):integer;

begin

result:= integer(m) - integer(w);

end;

procedure SaveBodyFB2;

var

i, j: integer;

S, ss: string;

oldStyle,

LastStyle, CurStyle: TmyStyle; // style

procedure StyleStucture;

begin

if CurStyle <> oldStyle then

begin

if SytleStack.Count = 0 then

begin

SytleStack.Add(TObject(CurStyle))

end

else

begin

LastStyle:= TmyStyle(SytleStack.Last);

case SubStyle(CurStyle,LastStyle) of

0: OutList.Add('</section>');

1: SytleStack.Add(TObject(CurStyle));

else

begin

OutList.Add('</section>');

while CurStyle <> LastStyle do

begin

SytleStack.Delete(SytleStack.Count-1);

OutList.Add('</section>');

LastStyle:= TmyStyle(SytleStack.Last);

end;

end;

end;// case

end;

OutList.Add('<section>');

OutList.Add('<title>');

end;

OutList.Add('<p>'+s+'</p>');

end; // StyleStucture;

begin

oldStyle:= ZZ; EndNotes_count:= 1;

// if

OutList.Add('<section>');

with Form1.ListBox1 do

for i:= 0 to Count - 1 do // просматриваем текст

begin

S:= Items[i];

Ss:= GetStyle(S, CurStyle); // получаем чистую строку и стиль

s:= '';

if ss <> '' then

for j:= 1 to length(Ss) do

begin // просматриваем строку

case ss[j] of

'~': begin // если это концевая сноска

S:= S + '<a l: href="#n_'+IntToStr(EndNotes_count)+'" type="note">'

+IntToStr(EndNotes_count)+'</a>';

inc(EndNotes_count); // увеличиваем счетчик сносок

end;

'^': S:= S + '́'; // ставим ударение

else S:= S + ss[j];

end; // case

end;

if (S = '') and (CurStyle <> Poem)

then

begin

OutList.Add('<empty-line/>');

continue;

end;

if (CurStyle <> oldStyle) and (CurStyle <> Auth) then

begin

case oldStyle of // завершение предыдущего блока

Poem: OutList.Add('</stanza></poem>');

Epig: OutList.Add('</epigraph>');

Citat: OutList.Add('</cite>');

H1..H5: OutList.Add('</title>');

end; // case завершение предыдущего блока

case CurStyle of // начало блока

Poem: OutList.Add('<poem><stanza>');

Epig: OutList.Add('<epigraph>');

Citat: OutList.Add('<cite>');

end; // case начало блока

end;

// анализ стилей

case CurStyle of // в зависимости от стиля абзаца

Norm,Epig,Citat: OutList.Add('<p>'+S+'</p>');

H1..H5: StyleStucture; // Heading

Sub: OutList.Add('<subtitle>'+s+'</subtitle>'); // Subtitle

Poem: begin

if S = ''

then OutList.Add('</stanza><stanza>')

else OutList.Add('<v>'+S+'</v>');

end;

Auth: begin

OutList.Add('<text-author>'+S+'</text-author>');

if oldStyle in [Poem, Epig, Citat]

then CurStyle:= oldStyle;

end;

None: continue; //None

end; // case

oldStyle:= CurStyle;

end; // for просмотр текста

if SytleStack.Count > 0 then

begin // закрываем все открытые секции

while SytleStack.Count > 0 do

begin

SytleStack.Delete(SytleStack.Count-1);

OutList.Add('</section>');

end;

end;

OutList.Add('</section>');

OutList.Add('</body>');

end;

procedure SaveEndnotes;

var

S: string;

i: integer;

begin

if Form1.EndNotesList.Items.Count = 0 then exit; //<a type="note" l: href="#n_1">[1]</a>

OutList.Add('<body name="notes"><title><p>Примечания</p></title>');

for i:= 0 to Form1.EndNotesList.Items.Count - 1 do

begin

S:= Form1.EndNotesList.Items[i];

OutList.Add('<section id="n_'+IntToStr(i+1)+'"><title><p>'+IntToStr(i+1)+'</p>');

OutList.Add('</title><p>'+S+'</p>');

OutList.Add('</section>');

end;

OutList.Add('</body>');

end;

Procedure Make_fb2(S: string);

begin //

1 ... 5 6 7 8 9 ... 12 ВПЕРЕД
Комментариев (0)
×