Вход/Регистрация
Пишем программу для создания книг FB2
вернуться

Карпов Юрий

Шрифт:

case ss[j] of

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

S:= S + '<a l: href="#" 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(''+S+'');

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="#">[1]</a>

OutList.Add('<body name="notes"><title>Примечания</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>'+IntToStr(i+1)+'');

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

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

end;

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

end;

Procedure Make_fb2(S: string);

begin //

if Form1.ListBox1.Items.Count = 0 then exit;

SytleStack.Clear;

OutList.Clear;

SaveDescription;

SaveBodyFB2;

SaveEndnotes;

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

OutList.SaveToFile(S); //++ +

showMessage('Done.');

end;

function BookHaveName: boolean;

begin

with Form1 do

result:= (book_title.Text <> '') and

(FB2_file.Text <> '') and

(GenresBox.Count > 0);

end;

procedure TForm1.SaveasFB21Click(Sender: TObject);

begin

if not BookHaveName then

begin

PageControl1.ActivePageIndex:= 0;

ShowMessage('Fill the form.');

exit;

end;

SaveDialog1.FileName:= form1.FB2_file.Text;

if SaveDialog1.Execute then

Make_fb2(SaveDialog1.FileName);

end;

function SetStyle(n: TmyStyle):string;

begin

case n of

Norm: result:= ' N';

Epig: result:= ' E';

Auth: result:= ' A';

H1: result:= 'H1';

H2: result:= 'H2';

H3: result:= 'H3';

  • Читать дальше
  • 1
  • ...
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • ...

Ебукер (ebooker) – онлайн-библиотека на русском языке. Книги доступны онлайн, без утомительной регистрации. Огромный выбор и удобный дизайн, позволяющий читать без проблем. Добавляйте сайт в закладки! Все произведения загружаются пользователями: если считаете, что ваши авторские права нарушены – используйте форму обратной связи.

Полезные ссылки

  • Моя полка

Контакты

  • chitat.ebooker@gmail.com

Подпишитесь на рассылку: