Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add in-image book reader #222

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e571a68
add first version of BookExtract
LinqLover Nov 21, 2023
fa6d126
book-extract: fix baseline for sb-tree-sitter
LinqLover Nov 21, 2023
964aab8
update todos for extract-book
LinqLover Nov 21, 2023
bf876b3
extract-book: make texts and images aware of UI theme and scale facto…
LinqLover Nov 21, 2023
1516397
document storing and reading of books
LinqLover Nov 21, 2023
974043c
allow updates via metacello
LinqLover Nov 21, 2023
955817f
fix text selection for squeak60
LinqLover Nov 21, 2023
eeb02e1
fix extension method prefix
LinqLover Nov 21, 2023
0d72c8b
fix inline clickable images
LinqLover Nov 21, 2023
6aa4d21
handle math mode
LinqLover Nov 21, 2023
e1842b6
book: add compatibility patches for squeak60
LinqLover Nov 21, 2023
d1547e3
fix use of compatibility methods
LinqLover Nov 21, 2023
38c9024
fix handling of \SQUEAKVERSION and \SqVersionSwitch
LinqLover Nov 25, 2023
0784c92
improve parsing of math
LinqLover Nov 25, 2023
6ff0427
fix linebreaks after \\
LinqLover Nov 25, 2023
d2b7fc7
parse \~ correctly
LinqLover Nov 25, 2023
eae9b2e
add pdf urls
LinqLover Nov 25, 2023
6de5db4
update extractor example with squeakVersion and pdfUrl
LinqLover Nov 25, 2023
b1c98ee
update and extend SBEHelp prosa
LinqLover Nov 25, 2023
c3ddb21
ci: upload generated figures as artifact
LinqLover Nov 25, 2023
efce7ed
fix ci slip
LinqLover Nov 25, 2023
f543db6
update serialization
LinqLover Nov 25, 2023
a424ed7
handle further character commands
LinqLover Nov 26, 2023
eec5d41
ignore bibliography
LinqLover Nov 26, 2023
24e92d4
extract-book: add index (DOM, links, (de)serialization)
LinqLover Nov 26, 2023
67731ff
book node: cache anchorLabels
LinqLover Nov 26, 2023
3b5a440
fix handling of pendingLabels for formatted texts
LinqLover Nov 26, 2023
72a0c92
refactor: move label opening from book node to label link
LinqLover Nov 26, 2023
51ce8c4
update preface and mention index
LinqLover Nov 26, 2023
61df36d
check book for invalid links
LinqLover Nov 26, 2023
d763eb4
docs
LinqLover Nov 26, 2023
44bd868
avoid duplicate #withBlanksTrimmed
LinqLover Nov 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 8 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,18 @@ jobs:
run: mv SBE.pdf SBE-${{ matrix.smalltalk }}.pdf
env:
SQUEAK_VERSION: ${{ matrix.smalltalk }}
- name: 💾 Upload artifact
- name: 💾 Upload PDF
uses: actions/upload-artifact@master
with:
name: book-${{ matrix.smalltalk }}
path: SBE-${{ matrix.smalltalk }}.pdf
- name: 💾 Upload figures (for debugging and local builds)
# run even if figures failed but only when it has run
if: steps.figures.outcome == 'success' || steps.figures.outcome == 'failure'
uses: actions/upload-artifact@master
with:
name: figures-${{ matrix.smalltalk }}
path: ./*/**/*.png
- if: (steps.figures.outcome == 'failure')
name: Check DEBUG_FIGURES
run: |
Expand Down
5 changes: 4 additions & 1 deletion .squot
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ OrderedDictionary {
'SmalltalkSources/SBE-Extract.package' : #SquotCypressCodeSerializer,
'SmalltalkSources/BaselineOfSBE.package' : #SquotCypressCodeSerializer,
'SmalltalkSources/SBE-Monticello.package' : #SquotCypressCodeSerializer,
'SmalltalkSources/SBE-Tests.package' : #SquotCypressCodeSerializer
'SmalltalkSources/SBE-Tests.package' : #SquotCypressCodeSerializer,
'SmalltalkSources/SBE-Book.package' : #SquotCypressCodeSerializer,
'SmalltalkSources/SBE-ExtractBook.package' : #SquotCypressCodeSerializer,
'SmalltalkSources/SBE-BookCompatibility-Squeak60.package' : #SquotCypressCodeSerializer
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ baseline: spec
spec baseline: 'FileSystem' with: [spec
repository: 'github://squeak-smalltalk/squeak-filesystem:master/src';
loads: #('default' 'tests')].
spec baseline: 'SBTreeSitter' with: [spec
repository: 'github://hpi-swa-lab/sb-tree-sitter:master/packages';
loads: 'Sandblocks-TreeSitter'].
spec
package: #'SBE-Book';
package: #'SBE-Environment';
package: #'SBE-Extract' with: [spec requires: #('FileSystem')];
package: #'SBE-ExtractBook' with: [
spec requires: #(#'SBE-Book' 'FileSystem' 'SBTreeSitter')];
package: #'SBE-Monticello';
package: #'SBE-Morphic';
package: #'SBE-Quinto';
Expand All @@ -24,4 +30,9 @@ baseline: spec
#'SBE-QuickTour'
#'SBE-Streams'
#'SBE-Testing'
#'SBE-Tests')].
#'SBE-Tests')].

spec for: #(#'squeak6.0.x.release') do: [
spec package: #'SBE-BookCompatibility-Squeak60'.
spec package: #'SBE-Book' with: [
spec includes: #'SBE-BookCompatibility-Squeak60']].
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
accessing
customProjectAttributes

| attributes |
attributes := super customProjectAttributes.
(Smalltalk classNamed: #SystemVersion) ifNotNil: [:versionClass |
versionClass current isRelease ifTrue:
[attributes := attributes ,
(MetacelloPlatform current defaultPlatformAttributes
select: [:ea | ea matchesRegex: 'squeak\d.*']
thenCollect: [:ea | ea , '.release'])]].
^ attributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
projectClass

^ (self environment classNamed: #MetacelloCypressBaselineProject) ifNil: [super projectClass]
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
"class" : {
},
"instance" : {
"baseline:" : "ct 4/26/2021 18:32" } }
"baseline:" : "ct 11/21/2023 21:15",
"customProjectAttributes" : "ct 11/7/2023 12:22",
"projectClass" : "ct 11/21/2023 19:54" } }
4 changes: 4 additions & 0 deletions SmalltalkSources/SBE-Book.package/.filetree
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"noMethodMetaData" : true,
"separateMethodMetaAndSource" : false,
"useCypressPropertiesFile" : true }
6 changes: 6 additions & 0 deletions SmalltalkSources/SBE-Book.package/.squot-contents
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SquotTrackedObjectMetadata {
#objectClassName : #PackageInfo,
#id : UUID [ '6332283563594a83a7e250aeafb5702d' ],
#objectsReplacedByNames : true,
#serializer : #SquotCypressCodeSerializer
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*SBE-Book-converting
asSbeTextAnchor

^ SBETextAnchor new
copySameFrom: self asTextAnchor
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*SBE-Book-converting
asSbeTextAnchorWithExtent: extent

^ self asSbeTextAnchor
extent: extent;
yourself
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*SBE-Book-converting
asSbeTextAnchorWithExtent: extent dyeMode: dyeMode

^ (self asSbeTextAnchorWithExtent: extent)
dyeMode: dyeMode;
yourself
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"class" : {
},
"instance" : {
"asSbeTextAnchor" : "ct 11/15/2023 19:38",
"asSbeTextAnchorWithExtent:" : "ct 11/21/2023 18:00",
"asSbeTextAnchorWithExtent:dyeMode:" : "ct 11/21/2023 18:16" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
"name" : "Form" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*SBE-Book-converting
sbeStoreHtmlString

^ self fullPrintString
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"class" : {
},
"instance" : {
"sbeStoreHtmlString" : "ct 11/15/2023 20:14" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
"name" : "Object" }
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
bookIndex: aBookIndex

bookIndex := aBookIndex.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
bookIndex

^ bookIndex
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
canonicalHierarchyOrder

^ 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
index: anInteger

self assert: anInteger isNil.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
index

^ nil
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
pdfUrl: aUrl

pdfUrl := aUrl asUrl.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
pdfUrl

^ pdfUrl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
pdfUrlFragment

^ nil
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
converting
storeOn: aStream

aStream nextPutAll:
('({1}
pdfUrl: {2};
bookIndex: {3};
yourself)' format:
{String streamContents: [:stream | super storeOn: stream].
self pdfUrl storeString.
self bookIndex storeString})
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
converting
textForHelp

| helpText index |
helpText := super textForHelp.

self flag: #hacked. "There is too much ill-parsed nonsense before the actual title right now."
index := helpText findString: self title.
index = 0 ifTrue: [^ helpText].

^ (helpText allButFirst: index + self title size) withBlanksTrimmed
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
type

^ #book
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"class" : {
},
"instance" : {
"bookIndex" : "ct 11/26/2023 18:00",
"bookIndex:" : "ct 11/26/2023 18:00",
"canonicalHierarchyOrder" : "ct 11/8/2023 22:38",
"index" : "ct 11/25/2023 23:09",
"index:" : "ct 11/25/2023 23:09",
"pdfUrl" : "ct 11/24/2023 18:38",
"pdfUrl:" : "ct 11/24/2023 18:38",
"pdfUrlFragment" : "ct 11/24/2023 18:30",
"storeOn:" : "ct 11/26/2023 18:01",
"textForHelp" : "ct 11/26/2023 18:53",
"type" : "ct 11/25/2023 19:50" } }
15 changes: 15 additions & 0 deletions SmalltalkSources/SBE-Book.package/SBEBook.class/properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"category" : "SBE-Book",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
"pdfUrl",
"bookIndex" ],
"name" : "SBEBook",
"pools" : [
],
"super" : "SBEBookNode",
"type" : "normal" }
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
canonicalHierarchyOrder

^ 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
accessing
pdfUrlFragment

^ '{1}.{2}' format:
{self typeName. self index}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
type

^ #chapter
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"class" : {
},
"instance" : {
"canonicalHierarchyOrder" : "ct 11/8/2023 22:38",
"pdfUrlFragment" : "ct 11/25/2023 19:52",
"type" : "ct 11/25/2023 19:50" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"category" : "SBE-Book",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
],
"name" : "SBEBookChapter",
"pools" : [
],
"super" : "SBEBookNode",
"type" : "normal" }
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
instance creation
on: aBookNode

^ self new
bookNode: aBookNode;
yourself
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
debugging
allInvalidLinks

^ self invalidLinks ,
(self subtopics gather: [:topic | topic allInvalidLinks])
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
book

^ self bookNode book
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
bookNode: aBookNode

bookNode := aBookNode.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
bookNode

^ bookNode
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
contents

^ self bookNode fullTextForHelp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
debugging
invalidLinks

^ ((self bookNode text ifNil: [^ #()]) sbeAllAttributes
select: [:attr | attr isKindOf: SBETextLabelLink]
thenCollect: [:attr | attr label])
withoutDuplicates
select: [:label | (self book pathToLabel: label) isNil]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
key: anObject
"ignore - compatibility for subtopics of ClassBasedHelpTopic"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
key

^ self title
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tools
openInPDF

^ self bookNode openInPDF
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
testing
shouldStyle

^ false
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
accessing
subtopics

^ subtopics ifNil: [subtopics :=
self bookNode childrenForHelp
withIndexCollect: [:child :index |
child asHelpTopic
priority: index;
yourself]]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
title

^ self bookNode title asString
Loading
Loading