Class: Eleanor::Screenplay

Inherits:
Object
  • Object
show all
Defined in:
lib/eleanor.rb,
lib/eleanor/parser.rb,
lib/eleanor/hpdfpaper.rb

Overview

Encapsulates paragraphs and pages.

Note that Eleanor.load_config dynamically adds both class and instance methods to Screenplay depending on the options present in the user’s configuration file. See “Configuration” in the README.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeScreenplay

Returns a new instance of Screenplay.



425
426
427
428
429
430
# File 'lib/eleanor.rb', line 425

def initialize
  @paras= []
  @title_pages= []
  @pages= [Page.new(self, 1)]
  initialize_paper!
end

Instance Attribute Details

#pagesObject (readonly)

Array of Page objects. Filled in during pagination.



410
411
412
# File 'lib/eleanor.rb', line 410

def pages
  @pages
end

#parasObject (readonly)

Array of Paragraph objects. Filled in during parsing, used during pagination.



414
415
416
# File 'lib/eleanor.rb', line 414

def paras
  @paras
end

#title_pagesObject (readonly)

Array of TitlePage objects. Filled in during parsing.



417
418
419
# File 'lib/eleanor.rb', line 417

def title_pages
  @title_pages
end

Instance Method Details

#authorObject

The screenplay’s author, nil if none.



420
421
422
423
# File 'lib/eleanor.rb', line 420

def author
  @title_pages.each { |tp| tp.author and return tp.author }
  nil
end

#initialize_paper!Object

A required method in the backend. See lib/eleanor/hpdfpaper.rb.



238
239
240
241
242
243
244
245
# File 'lib/eleanor/hpdfpaper.rb', line 238

def initialize_paper!
  @pdf= HPDFDoc.new
  font_name= (%r{[\./\\]} =~ self.font ?
              @pdf.load_ttfont_from_file(self.font, HPDFDoc::HPDF_TRUE) :
              self.font)
  @pdf_font= @pdf.get_font(font_name, nil)
  @first_pdf_page= add_pdf_page(@pages.first)
end

#line_heightObject

A required method in the backend. See lib/eleanor/hpdfpaper.rb.



248
249
250
# File 'lib/eleanor/hpdfpaper.rb', line 248

def line_height
  self.line_height_points.points
end

#paginate!Object

Paginates the screenplay according to its and all the constraints of its paragraphs.



434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
# File 'lib/eleanor.rb', line 434

def paginate!
  @paras.each do |para|
    new_para= @pages.last.push_para(para)
    unless new_para.nil?
      new_paras= [new_para]
      if new_para.split_state == :whole
        while @pages.last.paras.last.keep_with_next? new_paras.first
          new_paras.unshift(@pages.last.paras.pop)
          if @pages.last.paras.empty?
            raise "pagination error: string of keep-with-nexts larger " \
                  "than one page; occured at:\n  #{para}"
          end
        end
      end
      new_page= Page.new(self, @pages.size + 1)
      new_paras.each do |p|
        new_page_para= new_page.push_para(p)
        if new_page_para
          raise "pagination error: string of keep-with-nexts larger than " \
                "one page:\n  #{new_page_para}"
        end
      end
      first_para= new_page.paras.first
      if first_para.is_a?(CharacterCue) && first_para.split_state == :widow
        @pages.last.push_para(More.new(self), true)
      end
      @pages << new_page
    end
  end
  @pages
end

#parse!(filename) ⇒ Object

Parses the plain text screenplay at filename. Returns nil if parsing failed and an array of paragraphs if it succeeded. The paras attribute will be valid if parsing is successful.



469
470
471
# File 'lib/eleanor.rb', line 469

def parse! filename
  parse_! filename
end

#parse_!(filename) ⇒ Object



469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
# File 'lib/eleanor/parser.rb', line 469

def parse_! filename
  lines= []
  last_char_cue= nil
  classes= nil
  # these are needed by ragel
  data= ''
  eof= nil
  
# line 478 "lib/eleanor/parser.rb"
class << self
	attr_accessor :_parser_actions
	private :_parser_actions, :_parser_actions=
end
self._parser_actions = [
	0, 1, 0, 1, 1, 1, 2, 1, 
	4, 1, 5, 1, 6, 1, 7, 1, 
	12, 1, 13, 1, 14, 1, 15, 1, 
	20, 1, 21, 1, 22, 1, 23, 2, 
	0, 8, 2, 0, 16, 2, 1, 9, 
	2, 1, 17, 2, 3, 7, 2, 6, 
	18, 2, 7, 19, 2, 14, 0, 2, 
	14, 10, 2, 15, 1, 2, 15, 11, 
	2, 20, 18, 2, 21, 19, 3, 0, 
	16, 8, 3, 1, 17, 9, 3, 3, 
	7, 19, 3, 5, 13, 7, 3, 14, 
	0, 10, 3, 14, 0, 16, 3, 15, 
	1, 11, 3, 15, 1, 17, 4, 1, 
	17, 7, 19, 4, 5, 13, 7, 19, 
	4, 14, 0, 16, 10, 4, 15, 1, 
	17, 11, 4, 21, 19, 15, 11, 5, 
	1, 17, 7, 19, 9, 5, 15, 5, 
	13, 7, 11, 6, 15, 1, 17, 7, 
	19, 11
]

class << self
	attr_accessor :_parser_key_offsets
	private :_parser_key_offsets, :_parser_key_offsets=
end
self._parser_key_offsets = [
	0, 0, 4, 8, 11, 15, 19, 27, 
	35, 39, 43, 50, 54, 58, 63, 64, 
	66, 69, 76, 78, 83, 84, 85, 86, 
	87, 95, 102, 106, 110, 111, 112, 116, 
	117, 122, 123, 128, 133, 138, 143, 148, 
	152, 156, 161, 166, 167, 172, 176, 180, 
	188, 198, 204, 208, 209, 210, 219, 229, 
	238, 244, 248, 249, 250, 251, 252, 253, 
	254, 259, 264, 269, 274, 279, 284, 289, 
	294, 299, 304, 309, 314, 319, 324, 333, 
	339, 343, 344, 345, 355, 365, 375, 385, 
	395, 405, 414, 418, 422, 423, 424, 430, 
	434, 435, 436, 446, 456, 466, 476, 486, 
	496, 506, 516, 526, 536, 546, 556, 566, 
	576, 577, 578, 587, 594, 600, 604, 611, 
	612, 613, 614, 615, 623, 627, 631, 637, 
	645, 646, 655, 656, 663, 669, 673, 679, 
	680, 681, 682, 690, 698, 708, 716
]

class << self
	attr_accessor :_parser_trans_keys
	private :_parser_trans_keys, :_parser_trans_keys=
end
self._parser_trans_keys = [
	10, 13, 11, 12, 9, 10, 13, 32, 
	32, 9, 13, 10, 13, 11, 12, 9, 
	10, 13, 32, 9, 10, 13, 32, 11, 
	12, 65, 90, 9, 10, 13, 32, 11, 
	12, 65, 90, 10, 13, 11, 12, 9, 
	10, 13, 32, 9, 10, 13, 32, 40, 
	11, 12, 10, 13, 11, 12, 9, 10, 
	13, 32, 9, 10, 13, 32, 40, 10, 
	10, 13, 41, 10, 13, 9, 10, 13, 
	32, 41, 11, 12, 9, 32, 9, 32, 
	40, 10, 13, 10, 10, 10, 10, 9, 
	10, 13, 32, 11, 12, 65, 90, 9, 
	10, 13, 32, 40, 11, 12, 10, 13, 
	11, 12, 9, 10, 13, 32, 10, 10, 
	9, 10, 13, 32, 10, 10, 13, 79, 
	11, 12, 10, 10, 13, 78, 11, 12, 
	10, 13, 84, 11, 12, 10, 13, 65, 
	11, 12, 10, 13, 71, 11, 12, 10, 
	13, 69, 11, 12, 10, 13, 11, 12, 
	9, 10, 13, 32, 32, 9, 13, 65, 
	90, 10, 13, 41, 11, 12, 10, 10, 
	13, 32, 11, 12, 10, 13, 11, 12, 
	9, 10, 13, 32, 9, 10, 13, 32, 
	11, 12, 65, 90, 9, 10, 13, 41, 
	11, 12, 32, 96, 123, 126, 9, 10, 
	13, 32, 11, 12, 9, 10, 13, 32, 
	10, 10, 9, 10, 13, 11, 12, 32, 
	96, 123, 126, 9, 10, 13, 32, 11, 
	12, 33, 96, 123, 126, 9, 10, 13, 
	11, 12, 32, 96, 123, 126, 9, 10, 
	13, 32, 11, 12, 9, 10, 13, 32, 
	10, 10, 10, 10, 10, 10, 10, 13, 
	69, 11, 12, 10, 13, 82, 11, 12, 
	10, 13, 73, 11, 12, 10, 13, 69, 
	11, 12, 10, 13, 83, 11, 12, 10, 
	13, 32, 11, 12, 10, 13, 79, 11, 
	12, 10, 13, 70, 11, 12, 10, 13, 
	32, 11, 12, 10, 13, 83, 11, 12, 
	10, 13, 72, 11, 12, 10, 13, 79, 
	11, 12, 10, 13, 84, 11, 12, 10, 
	13, 83, 11, 12, 9, 10, 13, 11, 
	12, 32, 96, 123, 126, 9, 10, 13, 
	32, 11, 12, 9, 10, 13, 32, 10, 
	10, 9, 10, 13, 79, 11, 12, 32, 
	96, 123, 126, 9, 10, 13, 78, 11, 
	12, 32, 96, 123, 126, 9, 10, 13, 
	84, 11, 12, 32, 96, 123, 126, 9, 
	10, 13, 65, 11, 12, 32, 96, 123, 
	126, 9, 10, 13, 71, 11, 12, 32, 
	96, 123, 126, 9, 10, 13, 69, 11, 
	12, 32, 96, 123, 126, 9, 10, 13, 
	11, 12, 32, 96, 123, 126, 10, 13, 
	11, 12, 9, 10, 13, 32, 10, 10, 
	9, 10, 13, 32, 11, 12, 9, 10, 
	13, 32, 10, 10, 9, 10, 13, 69, 
	11, 12, 32, 96, 123, 126, 9, 10, 
	13, 82, 11, 12, 32, 96, 123, 126, 
	9, 10, 13, 73, 11, 12, 32, 96, 
	123, 126, 9, 10, 13, 69, 11, 12, 
	32, 96, 123, 126, 9, 10, 13, 83, 
	11, 12, 32, 96, 123, 126, 9, 10, 
	13, 32, 11, 12, 33, 96, 123, 126, 
	9, 10, 13, 79, 11, 12, 32, 96, 
	123, 126, 9, 10, 13, 70, 11, 12, 
	32, 96, 123, 126, 9, 10, 13, 32, 
	11, 12, 33, 96, 123, 126, 9, 10, 
	13, 83, 11, 12, 32, 96, 123, 126, 
	9, 10, 13, 72, 11, 12, 32, 96, 
	123, 126, 9, 10, 13, 79, 11, 12, 
	32, 96, 123, 126, 9, 10, 13, 84, 
	11, 12, 32, 96, 123, 126, 9, 10, 
	13, 83, 11, 12, 32, 96, 123, 126, 
	10, 10, 10, 13, 32, 46, 58, 11, 
	12, 65, 90, 10, 13, 32, 11, 12, 
	65, 90, 9, 10, 13, 32, 11, 12, 
	9, 10, 13, 32, 9, 10, 13, 32, 
	40, 11, 12, 10, 10, 10, 10, 9, 
	10, 13, 32, 11, 12, 65, 90, 10, 
	13, 11, 12, 9, 10, 13, 32, 9, 
	10, 13, 32, 11, 12, 9, 10, 13, 
	32, 11, 12, 65, 90, 10, 10, 13, 
	32, 46, 58, 11, 12, 65, 90, 10, 
	10, 13, 32, 11, 12, 65, 90, 9, 
	10, 13, 32, 11, 12, 9, 10, 13, 
	32, 9, 10, 13, 32, 11, 12, 10, 
	10, 10, 9, 10, 13, 32, 77, 83, 
	11, 12, 9, 10, 13, 32, 77, 83, 
	11, 12, 9, 10, 13, 32, 77, 83, 
	11, 12, 65, 90, 9, 10, 13, 32, 
	77, 83, 11, 12, 9, 10, 13, 32, 
	77, 83, 11, 12, 0
]

class << self
	attr_accessor :_parser_single_lengths
	private :_parser_single_lengths, :_parser_single_lengths=
end
self._parser_single_lengths = [
	0, 2, 4, 1, 2, 4, 4, 4, 
	2, 4, 5, 2, 4, 5, 1, 0, 
	1, 5, 2, 3, 1, 1, 1, 1, 
	4, 5, 2, 4, 1, 1, 4, 1, 
	3, 1, 3, 3, 3, 3, 3, 2, 
	4, 1, 3, 1, 3, 2, 4, 4, 
	4, 4, 4, 1, 1, 3, 4, 3, 
	4, 4, 1, 1, 1, 1, 1, 1, 
	3, 3, 3, 3, 3, 3, 3, 3, 
	3, 3, 3, 3, 3, 3, 3, 4, 
	4, 1, 1, 4, 4, 4, 4, 4, 
	4, 3, 2, 4, 1, 1, 4, 4, 
	1, 1, 4, 4, 4, 4, 4, 4, 
	4, 4, 4, 4, 4, 4, 4, 4, 
	1, 1, 5, 3, 4, 4, 5, 1, 
	1, 1, 1, 4, 2, 4, 4, 4, 
	1, 5, 1, 3, 4, 4, 4, 1, 
	1, 1, 6, 6, 6, 6, 6
]

class << self
	attr_accessor :_parser_range_lengths
	private :_parser_range_lengths, :_parser_range_lengths=
end
self._parser_range_lengths = [
	0, 1, 0, 1, 1, 0, 2, 2, 
	1, 0, 1, 1, 0, 0, 0, 1, 
	1, 1, 0, 1, 0, 0, 0, 0, 
	2, 1, 1, 0, 0, 0, 0, 0, 
	1, 0, 1, 1, 1, 1, 1, 1, 
	0, 2, 1, 0, 1, 1, 0, 2, 
	3, 1, 0, 0, 0, 3, 3, 3, 
	1, 0, 0, 0, 0, 0, 0, 0, 
	1, 1, 1, 1, 1, 1, 1, 1, 
	1, 1, 1, 1, 1, 1, 3, 1, 
	0, 0, 0, 3, 3, 3, 3, 3, 
	3, 3, 1, 0, 0, 0, 1, 0, 
	0, 0, 3, 3, 3, 3, 3, 3, 
	3, 3, 3, 3, 3, 3, 3, 3, 
	0, 0, 2, 2, 1, 0, 1, 0, 
	0, 0, 0, 2, 1, 0, 1, 2, 
	0, 2, 0, 2, 1, 0, 1, 0, 
	0, 0, 1, 1, 2, 1, 1
]

class << self
	attr_accessor :_parser_index_offsets
	private :_parser_index_offsets, :_parser_index_offsets=
end
self._parser_index_offsets = [
	0, 0, 4, 9, 12, 16, 21, 28, 
	35, 39, 44, 51, 55, 60, 66, 68, 
	70, 73, 80, 83, 88, 90, 92, 94, 
	96, 103, 110, 114, 119, 121, 123, 128, 
	130, 135, 137, 142, 147, 152, 157, 162, 
	166, 171, 175, 180, 182, 187, 191, 196, 
	203, 211, 217, 222, 224, 226, 233, 241, 
	248, 254, 259, 261, 263, 265, 267, 269, 
	271, 276, 281, 286, 291, 296, 301, 306, 
	311, 316, 321, 326, 331, 336, 341, 348, 
	354, 359, 361, 363, 371, 379, 387, 395, 
	403, 411, 418, 422, 427, 429, 431, 437, 
	442, 444, 446, 454, 462, 470, 478, 486, 
	494, 502, 510, 518, 526, 534, 542, 550, 
	558, 560, 562, 570, 576, 582, 587, 594, 
	596, 598, 600, 602, 609, 613, 618, 624, 
	631, 633, 641, 643, 649, 655, 660, 666, 
	668, 670, 672, 680, 688, 697, 705
]

class << self
	attr_accessor :_parser_indicies
	private :_parser_indicies, :_parser_indicies=
end
self._parser_indicies = [
	1, 3, 2, 0, 1, 4, 5, 1, 
	2, 7, 7, 6, 8, 9, 7, 6, 
	8, 10, 11, 8, 7, 12, 13, 15, 
	12, 14, 16, 6, 18, 13, 15, 18, 
	19, 20, 17, 21, 23, 22, 17, 25, 
	26, 27, 25, 24, 25, 26, 27, 25, 
	29, 24, 28, 30, 32, 31, 28, 34, 
	35, 36, 34, 33, 34, 35, 36, 34, 
	29, 33, 35, 37, 33, 38, 39, 33, 
	38, 39, 40, 41, 39, 39, 33, 38, 
	42, 42, 31, 42, 42, 31, 31, 28, 
	40, 33, 30, 31, 26, 43, 21, 22, 
	18, 44, 46, 18, 45, 20, 17, 47, 
	48, 49, 47, 29, 24, 28, 51, 53, 
	52, 50, 51, 54, 55, 51, 52, 54, 
	52, 51, 52, 56, 13, 15, 56, 37, 
	13, 37, 1, 3, 58, 57, 0, 1, 
	2, 1, 3, 59, 57, 0, 1, 3, 
	60, 57, 0, 1, 3, 61, 57, 0, 
	1, 3, 62, 57, 0, 1, 3, 63, 
	57, 0, 64, 65, 57, 63, 64, 66, 
	67, 64, 57, 68, 68, 69, 6, 8, 
	9, 70, 68, 6, 8, 7, 8, 9, 
	71, 68, 6, 72, 73, 68, 71, 72, 
	74, 75, 72, 68, 12, 13, 15, 12, 
	76, 77, 6, 78, 79, 81, 82, 80, 
	16, 16, 6, 78, 79, 81, 78, 83, 
	6, 79, 84, 85, 79, 83, 84, 83, 
	79, 83, 78, 79, 81, 83, 16, 16, 
	6, 78, 79, 81, 86, 80, 16, 16, 
	6, 87, 88, 89, 80, 86, 86, 71, 
	87, 88, 89, 87, 80, 71, 88, 90, 
	91, 88, 80, 90, 80, 88, 80, 74, 
	68, 72, 68, 66, 57, 64, 57, 1, 
	3, 92, 57, 0, 1, 3, 93, 57, 
	0, 1, 3, 94, 57, 0, 1, 3, 
	95, 57, 0, 1, 3, 96, 57, 0, 
	1, 3, 97, 57, 0, 1, 3, 98, 
	57, 0, 1, 3, 99, 57, 0, 1, 
	3, 100, 57, 0, 1, 3, 101, 57, 
	0, 1, 3, 102, 57, 0, 1, 3, 
	103, 57, 0, 1, 3, 104, 57, 0, 
	1, 3, 63, 57, 0, 105, 106, 108, 
	107, 109, 109, 50, 105, 106, 108, 105, 
	107, 50, 106, 110, 111, 106, 107, 110, 
	107, 106, 107, 105, 106, 108, 113, 112, 
	109, 109, 50, 105, 106, 108, 114, 112, 
	109, 109, 50, 105, 106, 108, 115, 112, 
	109, 109, 50, 105, 106, 108, 116, 112, 
	109, 109, 50, 105, 106, 108, 117, 112, 
	109, 109, 50, 105, 106, 108, 118, 112, 
	109, 109, 50, 120, 121, 122, 112, 118, 
	118, 119, 123, 125, 124, 119, 123, 126, 
	127, 123, 124, 126, 124, 123, 124, 120, 
	121, 122, 120, 112, 119, 121, 128, 129, 
	121, 112, 128, 112, 121, 112, 105, 106, 
	108, 130, 112, 109, 109, 50, 105, 106, 
	108, 131, 112, 109, 109, 50, 105, 106, 
	108, 132, 112, 109, 109, 50, 105, 106, 
	108, 133, 112, 109, 109, 50, 105, 106, 
	108, 134, 112, 109, 109, 50, 105, 106, 
	108, 135, 112, 109, 109, 50, 105, 106, 
	108, 136, 112, 109, 109, 50, 105, 106, 
	108, 137, 112, 109, 109, 50, 105, 106, 
	108, 138, 112, 109, 109, 50, 105, 106, 
	108, 139, 112, 109, 109, 50, 105, 106, 
	108, 140, 112, 109, 109, 50, 105, 106, 
	108, 141, 112, 109, 109, 50, 105, 106, 
	108, 142, 112, 109, 109, 50, 105, 106, 
	108, 118, 112, 109, 109, 50, 48, 43, 
	44, 22, 21, 23, 143, 144, 144, 45, 
	20, 17, 21, 23, 143, 45, 20, 17, 
	144, 145, 146, 144, 45, 17, 148, 149, 
	150, 148, 147, 148, 149, 150, 148, 29, 
	147, 28, 149, 19, 145, 45, 10, 7, 
	4, 2, 152, 153, 155, 152, 154, 156, 
	151, 157, 159, 158, 151, 160, 161, 162, 
	160, 158, 160, 161, 162, 160, 158, 151, 
	163, 161, 162, 163, 154, 156, 151, 161, 
	158, 157, 159, 164, 165, 165, 154, 156, 
	151, 157, 158, 157, 159, 164, 154, 156, 
	151, 165, 166, 167, 165, 154, 151, 168, 
	169, 170, 168, 154, 168, 169, 170, 168, 
	154, 151, 169, 154, 166, 154, 153, 37, 
	152, 153, 155, 152, 172, 173, 171, 0, 
	47, 48, 49, 47, 172, 173, 174, 0, 
	12, 13, 15, 12, 176, 177, 175, 109, 
	50, 56, 13, 15, 56, 172, 173, 57, 
	0, 163, 161, 162, 163, 172, 173, 171, 
	0, 0
]

class << self
	attr_accessor :_parser_trans_targs_wi
	private :_parser_trans_targs_wi, :_parser_trans_targs_wi=
end
self._parser_trans_targs_wi = [
	1, 2, 0, 33, 3, 122, 4, 0, 
	5, 43, 6, 121, 7, 141, 0, 31, 
	53, 8, 24, 0, 114, 9, 0, 23, 
	0, 10, 6, 22, 11, 15, 12, 0, 
	21, 0, 13, 6, 14, 0, 16, 17, 
	18, 20, 19, 0, 139, 0, 113, 25, 
	140, 112, 26, 27, 0, 29, 6, 28, 
	30, 0, 34, 35, 36, 37, 38, 39, 
	40, 63, 41, 62, 0, 42, 44, 45, 
	46, 61, 47, 60, 0, 48, 49, 50, 
	0, 52, 54, 0, 6, 51, 55, 56, 
	57, 59, 47, 58, 65, 66, 67, 68, 
	69, 70, 71, 72, 73, 74, 75, 76, 
	77, 79, 80, 0, 82, 78, 6, 81, 
	0, 84, 85, 86, 87, 88, 89, 90, 
	94, 95, 97, 91, 0, 93, 47, 92, 
	47, 96, 99, 100, 101, 102, 103, 104, 
	105, 106, 107, 108, 109, 110, 111, 115, 
	116, 117, 120, 0, 118, 6, 119, 124, 
	123, 138, 0, 137, 129, 125, 0, 130, 
	126, 142, 128, 127, 131, 132, 133, 136, 
	134, 142, 135, 0, 32, 64, 0, 0, 
	83, 98
]

class << self
	attr_accessor :_parser_trans_actions_wi
	private :_parser_trans_actions_wi, :_parser_trans_actions_wi=
end
self._parser_trans_actions_wi = [
	0, 0, 21, 0, 19, 0, 0, 3, 
	0, 0, 1, 0, 27, 0, 102, 0, 
	0, 0, 0, 49, 0, 5, 43, 0, 
	82, 0, 11, 0, 0, 0, 7, 9, 
	0, 17, 0, 29, 0, 0, 0, 0, 
	15, 0, 0, 13, 5, 78, 0, 0, 
	11, 0, 0, 0, 58, 0, 52, 0, 
	0, 61, 0, 0, 0, 0, 0, 0, 
	0, 0, 55, 0, 37, 0, 0, 0, 
	0, 0, 31, 0, 127, 0, 0, 0, 
	74, 0, 0, 40, 34, 0, 0, 0, 
	0, 0, 70, 0, 0, 0, 0, 0, 
	0, 0, 0, 0, 0, 0, 0, 0, 
	0, 0, 0, 98, 0, 0, 90, 0, 
	117, 0, 0, 0, 0, 0, 0, 0, 
	0, 0, 0, 0, 94, 0, 86, 0, 
	112, 0, 0, 0, 0, 0, 0, 0, 
	0, 0, 0, 0, 0, 0, 0, 0, 
	0, 5, 0, 107, 0, 46, 0, 0, 
	0, 0, 67, 0, 0, 0, 25, 0, 
	0, 23, 0, 0, 0, 0, 0, 0, 
	0, 64, 0, 122, 0, 0, 133, 139, 
	0, 0
]

class << self
	attr_accessor :_parser_eof_actions
	private :_parser_eof_actions, :_parser_eof_actions=
end
self._parser_eof_actions = [
	0, 21, 21, 3, 3, 3, 102, 49, 
	43, 82, 82, 9, 17, 17, 0, 17, 
	17, 17, 9, 9, 17, 9, 13, 43, 
	78, 82, 58, 58, 58, 58, 0, 0, 
	61, 21, 61, 61, 61, 61, 61, 61, 
	61, 37, 37, 3, 37, 37, 37, 127, 
	74, 40, 40, 40, 40, 40, 74, 74, 
	74, 74, 74, 74, 37, 37, 61, 61, 
	61, 61, 61, 61, 61, 61, 61, 61, 
	61, 61, 61, 61, 61, 61, 98, 98, 
	98, 98, 98, 117, 117, 117, 117, 117, 
	117, 117, 94, 94, 94, 94, 117, 117, 
	117, 117, 117, 117, 117, 117, 117, 117, 
	117, 117, 117, 117, 117, 117, 117, 117, 
	13, 43, 78, 78, 78, 107, 107, 49, 
	78, 3, 21, 67, 25, 25, 25, 67, 
	25, 67, 25, 67, 67, 67, 67, 67, 
	67, 0, 0, 0, 0, 0, 0
]

class << self
	attr_accessor :parser_start
end
self.parser_start = 138;
class << self
	attr_accessor :parser_first_final
end
self.parser_first_final = 138;
class << self
	attr_accessor :parser_error
end
self.parser_error = 0;

class << self
	attr_accessor :parser_en_main
end
self.parser_en_main = 138;

# line 119 "src/ragel/parser.rl"
  
# line 905 "lib/eleanor/parser.rb"
begin
	p ||= 0
	pe ||= data.length
	cs = parser_start
end
# line 120 "src/ragel/parser.rl"
  File.open(filename, 'r') do |file|
    file.each_line do |line|
      line << "\n" * 3 if file.eof?
      error= lambda do |expected|
        warn "#{filename}:#{file.lineno}: parse error: expected #{expected}:"
        warn "  #{@paras[-2]}" if @paras.length >= 2
        warn "  #{@paras[-1]}" if @paras.length >= 1
        warn "  #{line.inspect}"
      end
      consume= false
      # these are needed by ragel
      data= line
      p= 0
      pe= data.length
      
# line 927 "lib/eleanor/parser.rb"
begin
	_klen, _trans, _keys, _acts, _nacts = nil
	_goto_level = 0
	_resume = 10
	_eof_trans = 15
	_again = 20
	_test_eof = 30
	_out = 40
	while true
	_trigger_goto = false
	if _goto_level <= 0
	if p == pe
		_goto_level = _test_eof
		next
	end
	if cs == 0
		_goto_level = _out
		next
	end
	end
	if _goto_level <= _resume
	_keys = _parser_key_offsets[cs]
	_trans = _parser_index_offsets[cs]
	_klen = _parser_single_lengths[cs]
	_break_match = false
	
	begin
	  if _klen > 0
  _lower = _keys
  _upper = _keys + _klen - 1

  loop do
     break if _upper < _lower
     _mid = _lower + ( (_upper - _lower) >> 1 )

     if data[p] < _parser_trans_keys[_mid]
        _upper = _mid - 1
     elsif data[p] > _parser_trans_keys[_mid]
        _lower = _mid + 1
     else
        _trans += (_mid - _keys)
        _break_match = true
        break
     end
  end # loop
  break if _break_match
  _keys += _klen
  _trans += _klen
	  end
	  _klen = _parser_range_lengths[cs]
	  if _klen > 0
  _lower = _keys
  _upper = _keys + (_klen << 1) - 2
  loop do
     break if _upper < _lower
     _mid = _lower + (((_upper-_lower) >> 1) & ~1)
     if data[p] < _parser_trans_keys[_mid]
       _upper = _mid - 2
     elsif data[p] > _parser_trans_keys[_mid+1]
       _lower = _mid + 2
     else
       _trans += ((_mid - _keys) >> 1)
       _break_match = true
       break
     end
  end # loop
  break if _break_match
  _trans += _klen
	  end
	end while false
	_trans = _parser_indicies[_trans]
	cs = _parser_trans_targs_wi[_trans]
	if _parser_trans_actions_wi[_trans] != 0
		_acts = _parser_trans_actions_wi[_trans]
		_nacts = _parser_actions[_acts]
		_acts += 1
		while _nacts > 0
			_nacts -= 1
			_acts += 1
			case _parser_actions[_acts - 1]
when 0 then
# line 45 "src/ragel/parser.rl"
		begin
 classes= [Action]; consume= true 		end
# line 45 "src/ragel/parser.rl"
when 1 then
# line 46 "src/ragel/parser.rl"
		begin
 error.call('Action') 		end
# line 46 "src/ragel/parser.rl"
when 2 then
# line 49 "src/ragel/parser.rl"
		begin
 classes << CharacterCue 		end
# line 49 "src/ragel/parser.rl"
when 3 then
# line 50 "src/ragel/parser.rl"
		begin
 error.call('Action') 		end
# line 50 "src/ragel/parser.rl"
when 4 then
# line 53 "src/ragel/parser.rl"
		begin
 classes << Dialog 		end
# line 53 "src/ragel/parser.rl"
when 5 then
# line 54 "src/ragel/parser.rl"
		begin
 error.call('Dialog') 		end
# line 54 "src/ragel/parser.rl"
when 6 then
# line 57 "src/ragel/parser.rl"
		begin
 classes= [Insert]; consume= true 		end
# line 57 "src/ragel/parser.rl"
when 7 then
# line 58 "src/ragel/parser.rl"
		begin
 error.call('Insert') 		end
# line 58 "src/ragel/parser.rl"
when 8 then
# line 61 "src/ragel/parser.rl"
		begin
 classes= [MontageItem]; consume= true 		end
# line 61 "src/ragel/parser.rl"
when 9 then
# line 62 "src/ragel/parser.rl"
		begin
 error.call('MontageItem') 		end
# line 62 "src/ragel/parser.rl"
when 10 then
# line 65 "src/ragel/parser.rl"
		begin
 classes= [MontageHeading]; consume= true 		end
# line 65 "src/ragel/parser.rl"
when 11 then
# line 66 "src/ragel/parser.rl"
		begin
 error.call('MontageHeading') 		end
# line 66 "src/ragel/parser.rl"
when 12 then
# line 69 "src/ragel/parser.rl"
		begin
 classes << Parenthetical 		end
# line 69 "src/ragel/parser.rl"
when 13 then
# line 70 "src/ragel/parser.rl"
		begin
 error.call('Parenthetical') 		end
# line 70 "src/ragel/parser.rl"
when 14 then
# line 73 "src/ragel/parser.rl"
		begin
 classes= [SceneHeading]; consume= true 		end
# line 73 "src/ragel/parser.rl"
when 15 then
# line 74 "src/ragel/parser.rl"
		begin
 error.call('SceneHeading') 		end
# line 74 "src/ragel/parser.rl"
when 16 then
# line 77 "src/ragel/parser.rl"
		begin
 classes= [SlugLine]; consume= true 		end
# line 77 "src/ragel/parser.rl"
when 17 then
# line 78 "src/ragel/parser.rl"
		begin
 error.call('SlugLine') 		end
# line 78 "src/ragel/parser.rl"
when 18 then
# line 81 "src/ragel/parser.rl"
		begin
 classes= [Transition]; consume= true 		end
# line 81 "src/ragel/parser.rl"
when 19 then
# line 82 "src/ragel/parser.rl"
		begin
 error.call('Transition') 		end
# line 82 "src/ragel/parser.rl"
when 20 then
# line 87 "src/ragel/parser.rl"
		begin
 classes= [TitlePage]; consume= true 		end
# line 87 "src/ragel/parser.rl"
when 21 then
# line 88 "src/ragel/parser.rl"
		begin
 error.call('TitlePage') 		end
# line 88 "src/ragel/parser.rl"
when 22 then
# line 92 "src/ragel/parser.rl"
		begin
 classes= [] 		end
# line 92 "src/ragel/parser.rl"
when 23 then
# line 93 "src/ragel/parser.rl"
		begin
 consume= true 		end
# line 93 "src/ragel/parser.rl"
# line 1128 "lib/eleanor/parser.rb"
			end # action switch
		end
	end
	if _trigger_goto
		next
	end
	end
	if _goto_level <= _again
	if cs == 0
		_goto_level = _out
		next
	end
	p += 1
	if p != pe
		_goto_level = _resume
		next
	end
	end
	if _goto_level <= _test_eof
	if p == eof
	__acts = _parser_eof_actions[cs]
	__nacts =  _parser_actions[__acts]
	__acts += 1
	while __nacts > 0
		__nacts -= 1
		__acts += 1
		case _parser_actions[__acts - 1]
when 1 then
# line 46 "src/ragel/parser.rl"
		begin
 error.call('Action') 		end
# line 46 "src/ragel/parser.rl"
when 3 then
# line 50 "src/ragel/parser.rl"
		begin
 error.call('Action') 		end
# line 50 "src/ragel/parser.rl"
when 5 then
# line 54 "src/ragel/parser.rl"
		begin
 error.call('Dialog') 		end
# line 54 "src/ragel/parser.rl"
when 7 then
# line 58 "src/ragel/parser.rl"
		begin
 error.call('Insert') 		end
# line 58 "src/ragel/parser.rl"
when 9 then
# line 62 "src/ragel/parser.rl"
		begin
 error.call('MontageItem') 		end
# line 62 "src/ragel/parser.rl"
when 11 then
# line 66 "src/ragel/parser.rl"
		begin
 error.call('MontageHeading') 		end
# line 66 "src/ragel/parser.rl"
when 13 then
# line 70 "src/ragel/parser.rl"
		begin
 error.call('Parenthetical') 		end
# line 70 "src/ragel/parser.rl"
when 15 then
# line 74 "src/ragel/parser.rl"
		begin
 error.call('SceneHeading') 		end
# line 74 "src/ragel/parser.rl"
when 17 then
# line 78 "src/ragel/parser.rl"
		begin
 error.call('SlugLine') 		end
# line 78 "src/ragel/parser.rl"
when 19 then
# line 82 "src/ragel/parser.rl"
		begin
 error.call('Transition') 		end
# line 82 "src/ragel/parser.rl"
when 21 then
# line 88 "src/ragel/parser.rl"
		begin
 error.call('TitlePage') 		end
# line 88 "src/ragel/parser.rl"
# line 1211 "lib/eleanor/parser.rb"
		end # eof action switch
	end
	if _trigger_goto
		next
	end
end
	end
	if _goto_level <= _out
		break
	end
	end
	end
# line 135 "src/ragel/parser.rl"
      # collect lines until consume is set, i.e., we've seen a full
      # paragraph, in which case classes is non-nil
      lines << line
      if consume
        lines= lines.map { |l| l.strip }.reject { |l| l.empty? }
        unless lines.empty?
          if classes[0] == TitlePage
            @title_pages << TitlePage.new(:title   => lines[0],
                                          :author  => lines[1],
                                          :contact => lines[2..-1])
          else
            lines.each_with_index do |line, i|
              @paras << classes[i].new(self, line, last_char_cue)
              # remember the last character cue in the current scene
              if classes[i] == CharacterCue
                last_char_cue= @paras.last
              elsif classes[i] == SceneHeading
                last_char_cue= nil
              end
            end
          end
        end
        lines= []
      end
    end
  end
  cs < parser_first_final ? nil : @paras
end

#save_paper(out_filename, in_filename = nil) ⇒ Object

A required method in the backend. See lib/eleanor/hpdfpaper.rb.



253
254
255
256
257
258
259
# File 'lib/eleanor/hpdfpaper.rb', line 253

def save_paper out_filename, in_filename=nil
  out_filename ||= (File.join(File.dirname(in_filename),
                              File.basename(in_filename,
                                            File.extname(in_filename))) +
                    '.pdf')
  @pdf.save_to_file(out_filename)
end

#text_width(str) ⇒ Object

A required method in the backend. See lib/eleanor/hpdfpaper.rb.



262
263
264
# File 'lib/eleanor/hpdfpaper.rb', line 262

def text_width str
  @first_pdf_page.text_width(str).points
end

#titleObject

The screenplay’s title, nil if none.



474
475
476
477
# File 'lib/eleanor.rb', line 474

def title
  @title_pages.each { |tp| tp.title and return tp.title }
  nil
end

#to_s(paginated = true) ⇒ Object



479
480
481
482
483
484
485
# File 'lib/eleanor.rb', line 479

def to_s paginated=true
  if paginated
    @pages.inject('') { |str, page| "#{str}#{page}" }
  else
    @paras.inject('') { |str, para| "#{str}#{para}\n" }
  end
end

#write_to_paper!Object

A required method in the backend. See lib/eleanor/hpdfpaper.rb.



267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
# File 'lib/eleanor/hpdfpaper.rb', line 267

def write_to_paper!
  if self.title
    @pdf.set_info_attr(HPDFDoc::HPDF_INFO_TITLE, self.title.gsub(/_/, ''))
  end
  @pdf.set_info_attr(HPDFDoc::HPDF_INFO_AUTHOR, self.author) if self.author
  @pdf.set_info_attr(HPDFDoc::HPDF_INFO_CREATOR,
                     "#{Eleanor::NAME} #{Eleanor::VERSION}")
  @title_pages.each do |page|
    pdf_page= add_pdf_page(page, @first_pdf_page)
    page.write_to_paper(pdf_page, self.line_height_points)
  end
  @pages.each_with_index do |page, i|
    pdf_page= (i == 0 ? @first_pdf_page : add_pdf_page(page))
    page.write_to_paper(pdf_page, self.line_height_points)
  end
end