defuddle-cli 0.1.0 → 0.1.1

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.
package/dist/index.js CHANGED
@@ -22,7 +22,7 @@ globalThis.CSSRule = class {
22
22
  this.parentStyleSheet = null;
23
23
  }
24
24
  };
25
- // Add static properties
25
+ // Static properties
26
26
  Object.defineProperties(globalThis.CSSRule, {
27
27
  STYLE_RULE: { value: 1, writable: false },
28
28
  CHARSET_RULE: { value: 2, writable: false },
@@ -633,6 +633,15 @@ function setupDOMInterfaces(window) {
633
633
  catch (error) {
634
634
  console.warn('Warning: Could not set Range constructor:', error);
635
635
  }
636
+ // Add HTMLAnchorElement to global scope
637
+ try {
638
+ if (!window.HTMLAnchorElement) {
639
+ window.HTMLAnchorElement = globalThis.HTMLAnchorElement;
640
+ }
641
+ }
642
+ catch (error) {
643
+ console.warn('Warning: Could not set HTMLAnchorElement:', error);
644
+ }
636
645
  }
637
646
  catch (error) {
638
647
  console.error('Error in setupDOMInterfaces:', error);
@@ -857,6 +866,71 @@ globalThis.HTMLTableCaptionElement = class extends globalThis.HTMLElement {
857
866
  this.align = '';
858
867
  }
859
868
  };
869
+ globalThis.HTMLButtonElement = class extends globalThis.HTMLElement {
870
+ constructor() {
871
+ super();
872
+ this.disabled = false;
873
+ this.form = null;
874
+ this.formAction = '';
875
+ this.formEnctype = '';
876
+ this.formMethod = '';
877
+ this.formNoValidate = false;
878
+ this.formTarget = '';
879
+ this.name = '';
880
+ this.type = 'submit';
881
+ this.value = '';
882
+ this.menu = null;
883
+ }
884
+ };
885
+ // Add HTMLSpanElement interface
886
+ globalThis.HTMLSpanElement = class extends globalThis.HTMLElement {
887
+ constructor() {
888
+ super();
889
+ }
890
+ };
891
+ // Add HTMLDivElement interface
892
+ globalThis.HTMLDivElement = class extends globalThis.HTMLElement {
893
+ constructor() {
894
+ super();
895
+ this.align = '';
896
+ }
897
+ };
898
+ globalThis.HTMLAnchorElement = class extends globalThis.HTMLElement {
899
+ constructor() {
900
+ super();
901
+ this.href = '';
902
+ this.target = '';
903
+ this.download = '';
904
+ this.ping = '';
905
+ this.rel = '';
906
+ this.relList = {
907
+ length: 0,
908
+ value: '',
909
+ add: () => { },
910
+ contains: () => false,
911
+ item: () => null,
912
+ remove: () => { },
913
+ replace: () => false,
914
+ supports: () => false,
915
+ toggle: () => false,
916
+ [Symbol.iterator]: function* () { yield ''; return undefined; }
917
+ };
918
+ this.hreflang = '';
919
+ this.type = '';
920
+ this.text = '';
921
+ this.referrerPolicy = '';
922
+ this.origin = '';
923
+ this.protocol = '';
924
+ this.username = '';
925
+ this.password = '';
926
+ this.host = '';
927
+ this.hostname = '';
928
+ this.port = '';
929
+ this.pathname = '';
930
+ this.search = '';
931
+ this.hash = '';
932
+ }
933
+ };
860
934
  const program = new Command();
861
935
  program
862
936
  .name('defuddle')
@@ -965,6 +1039,10 @@ program
965
1039
  debug: options.debug
966
1040
  });
967
1041
  const result = await defuddle.parse();
1042
+ // If in debug mode, don't show content output
1043
+ if (options.debug) {
1044
+ process.exit(0);
1045
+ }
968
1046
  // Format output
969
1047
  let output;
970
1048
  let content;
package/dist/markdown.js CHANGED
@@ -233,14 +233,6 @@ export function createMarkdownContent(content, url) {
233
233
  return '\n\n' + items.join('\n\n') + '\n\n';
234
234
  }
235
235
  });
236
- turndownService.addRule('removeHiddenElements', {
237
- filter: function (node) {
238
- return (node.style.display === 'none');
239
- },
240
- replacement: function () {
241
- return '';
242
- }
243
- });
244
236
  turndownService.addRule('citations', {
245
237
  filter: (node) => {
246
238
  if (node instanceof Element) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "defuddle-cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Command line interface for Defuddle - extract article content from web pages",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
package/src/index.ts CHANGED
@@ -52,7 +52,7 @@ const __dirname = dirname(__filename);
52
52
  }
53
53
  };
54
54
 
55
- // Add static properties
55
+ // Static properties
56
56
  Object.defineProperties((globalThis as any).CSSRule, {
57
57
  STYLE_RULE: { value: 1, writable: false },
58
58
  CHARSET_RULE: { value: 2, writable: false },
@@ -735,6 +735,15 @@ function setupDOMInterfaces(window: DOMWindow) {
735
735
  console.warn('Warning: Could not set Range constructor:', error);
736
736
  }
737
737
 
738
+ // Add HTMLAnchorElement to global scope
739
+ try {
740
+ if (!window.HTMLAnchorElement) {
741
+ window.HTMLAnchorElement = (globalThis as any).HTMLAnchorElement as any;
742
+ }
743
+ } catch (error) {
744
+ console.warn('Warning: Could not set HTMLAnchorElement:', error);
745
+ }
746
+
738
747
  } catch (error) {
739
748
  console.error('Error in setupDOMInterfaces:', error);
740
749
  // Don't throw the error, just log it
@@ -971,6 +980,75 @@ const window = dom.window;
971
980
  align: string = '';
972
981
  };
973
982
 
983
+ (globalThis as any).HTMLButtonElement = class extends (globalThis as any).HTMLElement {
984
+ constructor() {
985
+ super();
986
+ }
987
+ disabled: boolean = false;
988
+ form: HTMLFormElement | null = null;
989
+ formAction: string = '';
990
+ formEnctype: string = '';
991
+ formMethod: string = '';
992
+ formNoValidate: boolean = false;
993
+ formTarget: string = '';
994
+ name: string = '';
995
+ type: string = 'submit';
996
+ value: string = '';
997
+ menu: HTMLMenuElement | null = null;
998
+ };
999
+
1000
+ // Add HTMLSpanElement interface
1001
+ (globalThis as any).HTMLSpanElement = class extends (globalThis as any).HTMLElement {
1002
+ constructor() {
1003
+ super();
1004
+ }
1005
+ };
1006
+
1007
+ // Add HTMLDivElement interface
1008
+ (globalThis as any).HTMLDivElement = class extends (globalThis as any).HTMLElement {
1009
+ constructor() {
1010
+ super();
1011
+ }
1012
+ align: string = '';
1013
+ };
1014
+
1015
+ (globalThis as any).HTMLAnchorElement = class extends (globalThis as any).HTMLElement {
1016
+ constructor() {
1017
+ super();
1018
+ }
1019
+ href: string = '';
1020
+ target: string = '';
1021
+ download: string = '';
1022
+ ping: string = '';
1023
+ rel: string = '';
1024
+ relList: DOMSettableTokenList = {
1025
+ length: 0,
1026
+ value: '',
1027
+ add: () => {},
1028
+ contains: () => false,
1029
+ item: () => null,
1030
+ remove: () => {},
1031
+ replace: () => false,
1032
+ supports: () => false,
1033
+ toggle: () => false,
1034
+ [Symbol.iterator]: function*() { yield ''; return undefined; }
1035
+ } as unknown as DOMSettableTokenList;
1036
+ hreflang: string = '';
1037
+ type: string = '';
1038
+ text: string = '';
1039
+ referrerPolicy: string = '';
1040
+ origin: string = '';
1041
+ protocol: string = '';
1042
+ username: string = '';
1043
+ password: string = '';
1044
+ host: string = '';
1045
+ hostname: string = '';
1046
+ port: string = '';
1047
+ pathname: string = '';
1048
+ search: string = '';
1049
+ hash: string = '';
1050
+ };
1051
+
974
1052
  const program = new Command();
975
1053
 
976
1054
  program
@@ -1087,6 +1165,11 @@ program
1087
1165
 
1088
1166
  const result = await defuddle.parse();
1089
1167
 
1168
+ // If in debug mode, don't show content output
1169
+ if (options.debug) {
1170
+ process.exit(0);
1171
+ }
1172
+
1090
1173
  // Format output
1091
1174
  let output: string;
1092
1175
  let content: string;
package/src/markdown.ts CHANGED
@@ -283,17 +283,6 @@ export function createMarkdownContent(content: string, url: string) {
283
283
  }
284
284
  });
285
285
 
286
- turndownService.addRule('removeHiddenElements', {
287
- filter: function (node) {
288
- return (
289
- node.style.display === 'none'
290
- );
291
- },
292
- replacement: function () {
293
- return '';
294
- }
295
- });
296
-
297
286
  turndownService.addRule('citations', {
298
287
  filter: (node: Node): boolean => {
299
288
  if (node instanceof Element) {