konjac 0.2.9.5 → 0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,120 +0,0 @@
1
- #!/usr/bin/osascript
2
- -- round up ASCII characters used for formatting in Word
3
- global bell
4
- global line_feed
5
- global form_feed
6
- global carriage_return
7
- global format_chars
8
-
9
- -- strip line breaks and formatting characters
10
- to strip_line_breaks(this_line)
11
- try
12
- -- remove last character until no it's no longer an excluded character
13
- repeat while last character of this_line is in format_chars
14
- set this_line to characters 1 thru -2 of this_line as string
15
- end repeat
16
- return this_line as text
17
- on error
18
- return ""
19
- end try
20
- end strip_line_breaks
21
-
22
- to get_posix_path(mac_path)
23
- set result to POSIX path of mac_path
24
- end get_posix_path
25
-
26
- to extract(filename)
27
- tell application "Microsoft Excel"
28
- activate
29
- open filename
30
- set active_workbook to active workbook
31
- set ignored_content to {missing value, "", line_feed}
32
-
33
- -- set tags path to full path to active workbook with a .tags extension
34
- set workbook_path to full name of active_workbook
35
- set tags_path to workbook_path & ".diff"
36
-
37
- -- delete tags file if it already exists
38
- tell application "Finder"
39
- if exists file tags_path then
40
- delete file tags_path
41
- end if
42
- end tell
43
-
44
- -- open tags file for writing
45
- set tags_file to open for access file tags_path with write permission
46
- set eof of tags_file to 0
47
-
48
- write ("--- " & my get_posix_path(workbook_path)) to tags_file
49
- write line_feed to tags_file
50
- write ("+++ " & my get_posix_path(workbook_path)) to tags_file
51
- write line_feed to tags_file
52
-
53
- -- iterate through sheets
54
- set sheet_index to 1
55
- set sheet_count to count of sheets in active_workbook
56
-
57
- repeat while sheet_index is less than or equal to sheet_count
58
- set current_range to used range of sheet sheet_index in active_workbook
59
-
60
- -- iterate through rows
61
- set row_index to 1
62
- set row_count to count of rows of current_range
63
- set column_count to count of columns of current_range
64
-
65
- repeat while row_index is less than or equal to row_count
66
- -- iterate through columns
67
- set column_index to 1
68
-
69
- repeat while column_index is less than or equal to column_count
70
- -- get text content if it's available
71
- set text_content to my strip_line_breaks(formula of cell column_index of row row_index of current_range) as string
72
-
73
- -- replace "soft returns" (vertical tabs) with real returns
74
- set old_delimiters to AppleScript's text item delimiters
75
- set AppleScript's text item delimiters to carriage_return
76
- set split_content to every text item of text_content
77
- set AppleScript's text item delimiters to old_delimiters
78
-
79
- if text_content is not in ignored_content then
80
- write ("@@ " & sheet_index & ":" & row_index & "," & column_index & " @@") to tags_file
81
- write line_feed to tags_file
82
- repeat with text_line in split_content
83
- write ("-" & text_line) to tags_file as «class utf8»
84
- write line_feed to tags_file
85
- end repeat
86
- repeat with text_line in split_content
87
- write ("+" & text_line) to tags_file as «class utf8»
88
- write line_feed to tags_file
89
- end repeat
90
- end if
91
-
92
- set column_index to (column_index + 1)
93
- end repeat
94
-
95
- set row_index to (row_index + 1)
96
- end repeat
97
-
98
- -- increment sheet index
99
- set sheet_index to (sheet_index + 1)
100
- end repeat
101
-
102
- -- close everything
103
- close access tags_file
104
- end tell
105
- end extract
106
-
107
- -- initialize global variables, just formatting characters here
108
- to init_globals()
109
- set bell to ASCII character 7
110
- set line_feed to ASCII character 10
111
- set form_feed to ASCII character 12
112
- set carriage_return to ASCII character 13
113
- set format_chars to {bell, line_feed, form_feed, carriage_return}
114
- end init_globals
115
-
116
- -- main()
117
- on run argv
118
- init_globals()
119
- extract(item 1 of argv)
120
- end
@@ -1,112 +0,0 @@
1
- #!/usr/bin/osascript
2
- global numbers_as_text
3
- global line_feed
4
- global vertical_tab
5
- global carriage_return
6
-
7
- -- parses the headers/separators inside the tags file
8
- to parse_header(header, begin)
9
- set at_offset to begin
10
-
11
- repeat while character at_offset of header is in my numbers_as_text
12
- set at_offset to (at_offset + 1)
13
- end repeat
14
-
15
- return at_offset
16
- end parse_header
17
-
18
- to get_posix_path(mac_path)
19
- set result to POSIX path of mac_path
20
- end get_posix_path
21
-
22
- to import(filename)
23
- tell application "Microsoft Excel"
24
- activate
25
- open filename
26
- set active_workbook to active workbook
27
- set ignored_content to {missing value, "", line_feed}
28
-
29
- -- set tags path to full path to active workbook with a .tags extension
30
- set workbook_path to full name of active_workbook
31
- set tags_path to workbook_path & ".diff"
32
-
33
- -- read in tags
34
- set tags_file to open for access file tags_path
35
- set tags to (read tags_file for (get eof tags_file) ¬
36
- as «class utf8» using delimiter line_feed)
37
- set tag_index to 0
38
- set tag_length to length of tags
39
- close access tags_file
40
-
41
- set text_content to ""
42
-
43
- -- iterate through sheets
44
- set sheet_index to 0
45
- set prev_sheet_index to 0
46
- set row_index to 0
47
- set prev_row_index to 0
48
- set column_index to 0
49
- set prev_column_index to 0
50
- set is_new_tag to false
51
-
52
- repeat with current_line in tags
53
- if current_line starts with "@@ " then
54
- set colon_offset to my parse_header(current_line, 4)
55
- set sheet_index to text 4 thru (colon_offset - 1) ¬
56
- of current_line as number
57
- set comma_offset to my parse_header(current_line, colon_offset + 1)
58
- set row_index to text (colon_offset + 1) thru (comma_offset - 1) ¬
59
- of current_line as number
60
- set space_offset to my parse_header(current_line, comma_offset + 1)
61
- set column_index to text (comma_offset + 1) thru (space_offset - 1) ¬
62
- of current_line as number
63
- set is_new_tag to true
64
- else if current_line starts with "+" then
65
- if sheet_index is not 0 then
66
- set prev_sheet_index to sheet_index
67
- set prev_row_index to row_index
68
- set prev_column_index to column_index
69
-
70
- -- handle blank lines with soft returns
71
- if length of current_line is less than 2
72
- set this_content to ""
73
- else
74
- set this_content to text 2 thru (length of current_line) ¬
75
- of current_line
76
- end if
77
-
78
- -- add to text content, joining with a soft return for multiple lines
79
- if text_content is "" then
80
- set text_content to this_content
81
- else
82
- set text_content to (text_content & carriage_return & this_content)
83
- end if
84
- set is_new_tag to false
85
- end if
86
- end if
87
-
88
- -- increment tag index
89
- set tag_index to tag_index + 1
90
-
91
- -- write if we've moved to a new tag or reached the end of the file
92
- if text_content is not "" and (tag_index is tag_length or is_new_tag)
93
- set formula of cell prev_column_index of row prev_row_index of used range of sheet prev_sheet_index of active_workbook to text_content
94
- set text_content to ""
95
- end if
96
- end repeat
97
- end tell
98
- end import
99
-
100
- -- initialize global variables
101
- to init_globals()
102
- set numbers_as_text to {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0"}
103
- set line_feed to ASCII character 10
104
- set vertical_tab to ASCII character 11
105
- set carriage_return to ASCII character 13
106
- end init_globals
107
-
108
- -- main()
109
- on run argv
110
- init_globals()
111
- import(item 1 of argv)
112
- end run
@@ -1,116 +0,0 @@
1
- #!/usr/bin/osascript
2
- -- round up ASCII characters used for formatting in Word
3
- global bell
4
- global line_feed
5
- global form_feed
6
- global carriage_return
7
- global format_chars
8
-
9
- -- strip line breaks and formatting characters
10
- to strip_line_breaks(this_line)
11
- try
12
- -- remove last character until no it's no longer an excluded character
13
- repeat while last character of this_line is in format_chars
14
- set this_line to characters 1 thru -2 of this_line as string
15
- end repeat
16
- return this_line as text
17
- on error
18
- return ""
19
- end try
20
- end strip_line_breaks
21
-
22
- to get_posix_path(mac_path)
23
- set result to POSIX path of mac_path
24
- end get_posix_path
25
-
26
- to extract(filename)
27
- tell application "Microsoft PowerPoint"
28
- activate
29
- open filename
30
- set active_presentation to active presentation
31
- set ignored_content to {missing value, "", line_feed}
32
-
33
- -- set tags path to full path to active presentation with a .tags extension
34
- set presentation_path to (path of active_presentation) & ":" & ¬
35
- (name of active_presentation)
36
- set tags_path to presentation_path & ".diff"
37
-
38
- -- delete tags file if it already exists
39
- tell application "Finder"
40
- if exists file tags_path then
41
- delete file tags_path
42
- end if
43
- end tell
44
-
45
- -- open tags file for writing
46
- set tags_file to open for access file tags_path with write permission
47
- set eof of tags_file to 0
48
-
49
- write ("--- " & my get_posix_path(presentation_path)) to tags_file
50
- write line_feed to tags_file
51
- write ("+++ " & my get_posix_path(presentation_path)) to tags_file
52
- write line_feed to tags_file
53
-
54
- -- iterate through slides
55
- set slide_index to 1
56
- set slide_count to count of slides in active_presentation
57
-
58
- repeat while slide_index is less than or equal to slide_count
59
- set current_slide to slide slide_index in active_presentation
60
-
61
- -- iterate through shapes
62
- set shape_index to 1
63
- set shape_count to count of shapes in current_slide
64
-
65
- repeat while shape_index is less than or equal to shape_count
66
- -- set current shape
67
- set current_shape to shape shape_index of current_slide
68
-
69
- -- get text content if it's available
70
- set text_content to my strip_line_breaks(content of text range of text frame of current_shape) as string
71
-
72
- -- replace "soft returns" (vertical tabs) with real returns
73
- set old_delimiters to AppleScript's text item delimiters
74
- set AppleScript's text item delimiters to carriage_return
75
- set split_content to every text item of text_content
76
- set AppleScript's text item delimiters to old_delimiters
77
-
78
- if text_content is not in ignored_content then
79
- write ("@@ " & slide_index & "," & shape_index & " @@") to tags_file
80
- write line_feed to tags_file
81
- repeat with text_line in split_content
82
- write ("-" & text_line) to tags_file as «class utf8»
83
- write line_feed to tags_file
84
- end repeat
85
- repeat with text_line in split_content
86
- write ("+" & text_line) to tags_file as «class utf8»
87
- write line_feed to tags_file
88
- end repeat
89
- end if
90
-
91
- set shape_index to (shape_index + 1)
92
- end repeat
93
-
94
- -- increment slide index
95
- set slide_index to (slide_index + 1)
96
- end repeat
97
-
98
- -- close everything
99
- close access tags_file
100
- end tell
101
- end extract
102
-
103
- -- initialize global variables, just formatting characters here
104
- to init_globals()
105
- set bell to ASCII character 7
106
- set line_feed to ASCII character 10
107
- set form_feed to ASCII character 12
108
- set carriage_return to ASCII character 13
109
- set format_chars to {bell, line_feed, form_feed, carriage_return}
110
- end init_globals
111
-
112
- -- main()
113
- on run argv
114
- init_globals()
115
- extract(item 1 of argv)
116
- end
@@ -1,109 +0,0 @@
1
- #!/usr/bin/osascript
2
- global numbers_as_text
3
- global line_feed
4
- global vertical_tab
5
- global carriage_return
6
-
7
- -- parses the headers/separators inside the tags file
8
- to parse_header(header, begin)
9
- set at_offset to begin
10
-
11
- repeat while character at_offset of header is in my numbers_as_text
12
- set at_offset to (at_offset + 1)
13
- end repeat
14
-
15
- return at_offset
16
- end parse_header
17
-
18
- to get_posix_path(mac_path)
19
- set result to POSIX path of mac_path
20
- end get_posix_path
21
-
22
- to import(filename)
23
- tell application "Microsoft PowerPoint"
24
- activate
25
- open filename
26
- set active_presentation to active presentation
27
- set ignored_content to {missing value, "", line_feed}
28
-
29
- -- set tags path to full path to active presentation with a .tags extension
30
- set presentation_path to (path of active_presentation) & ":" & ¬
31
- (name of active_presentation)
32
- set tags_path to presentation_path & ".diff"
33
-
34
- -- read in tags
35
- set tags_file to open for access file tags_path
36
- set tags to (read tags_file for (get eof tags_file) ¬
37
- as «class utf8» using delimiter line_feed)
38
- set tag_index to 0
39
- set tag_length to length of tags
40
- close access tags_file
41
-
42
- set text_content to ""
43
-
44
- -- iterate through slides
45
- set slide_index to 0
46
- set prev_slide_index to 0
47
- set shape_index to 0
48
- set prev_shape_index to 0
49
- set is_new_tag to false
50
-
51
- repeat with current_line in tags
52
- if current_line starts with "@@ " then
53
- set comma_offset to my parse_header(current_line, 4)
54
- set slide_index to text 4 thru (comma_offset - 1) ¬
55
- of current_line as number
56
- set space_offset to my parse_header(current_line, comma_offset + 1)
57
- set shape_index to text (comma_offset + 1) thru (space_offset - 1) ¬
58
- of current_line as number
59
- set is_new_tag to true
60
- else if current_line starts with "+" then
61
- if slide_index is not 0 then
62
- set prev_slide_index to slide_index
63
- set prev_shape_index to shape_index
64
-
65
- -- handle blank lines with soft returns
66
- if length of current_line is less than 2
67
- set this_content to ""
68
- else
69
- set this_content to text 2 thru (length of current_line) ¬
70
- of current_line
71
- end if
72
-
73
- -- add to text content, joining with a soft return for multiple lines
74
- if text_content is "" then
75
- set text_content to this_content
76
- else
77
- set text_content to (text_content & carriage_return & this_content)
78
- end if
79
- set is_new_tag to false
80
- end if
81
- end if
82
-
83
- -- increment tag index
84
- set tag_index to tag_index + 1
85
-
86
- -- write if we've moved to a new tag or reached the end of the file
87
- if text_content is not "" and (tag_index is tag_length or is_new_tag)
88
- set content of text range of text frame of shape prev_shape_index ¬
89
- of slide prev_slide_index ¬
90
- of active presentation to text_content
91
- set text_content to ""
92
- end if
93
- end repeat
94
- end tell
95
- end import
96
-
97
- -- initialize global variables
98
- to init_globals()
99
- set numbers_as_text to {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0"}
100
- set line_feed to ASCII character 10
101
- set vertical_tab to ASCII character 11
102
- set carriage_return to ASCII character 13
103
- end init_globals
104
-
105
- -- main()
106
- on run argv
107
- init_globals()
108
- import(item 1 of argv)
109
- end run